Use bpy.app.binary_path_python as subprocess interpreter

This commit is contained in:
Ellwood Zwovic
2017-08-02 16:45:34 -07:00
parent 2825d0fc06
commit 3bb59b5ac2

View File

@@ -44,6 +44,10 @@ else:
import bpy import bpy
from collections import OrderedDict from collections import OrderedDict
import multiprocessing
mp_context = multiprocessing.get_context()
mp_context.set_executable(bpy.app.binary_path_python)
# global list of all known packages, indexed by name # global list of all known packages, indexed by name
_packages = OrderedDict() _packages = OrderedDict()
@@ -129,9 +133,8 @@ class SubprocMixin:
self._state = 'QUIT' self._state = 'QUIT'
def invoke(self, context, event): def invoke(self, context, event):
import multiprocessing
self.pipe_blender, self.pipe_subproc = multiprocessing.Pipe() self.pipe_blender, self.pipe_subproc = mp_context.Pipe()
# The subprocess should just be terminated when Blender quits. Without this, # The subprocess should just be terminated when Blender quits. Without this,
# Blender would hang while closing, until the subprocess terminates itself. # Blender would hang while closing, until the subprocess terminates itself.
@@ -183,14 +186,13 @@ class SubprocMixin:
def abort(self): def abort(self):
import time import time
# Allow the subprocess 10 seconds to repsond to our abort message. # Allow the subprocess 10 seconds to respond to our abort message.
self._abort_timeout = time.time() + 10 self._abort_timeout = time.time() + 10
self._state = 'ABORTING' self._state = 'ABORTING'
self.pipe_blender.send(messages.Abort()) self.pipe_blender.send(messages.Abort())
def _finish(self, context): def _finish(self, context):
import multiprocessing
try: try:
self.cancel(context) self.cancel(context)
except AttributeError: except AttributeError:
@@ -268,7 +270,6 @@ class PACKAGE_OT_install(SubprocMixin, bpy.types.Operator):
:rtype: multiprocessing.Process :rtype: multiprocessing.Process
""" """
import multiprocessing
self.msg_handlers = { self.msg_handlers = {
messages.Progress: self._subproc_progress, messages.Progress: self._subproc_progress,
@@ -289,7 +290,7 @@ class PACKAGE_OT_install(SubprocMixin, bpy.types.Operator):
self.log.debug("Using %s as install path", install_path) self.log.debug("Using %s as install path", install_path)
import addon_utils import addon_utils
proc = multiprocessing.Process(target=subproc.download_and_install_package, proc = mp_context.Process(target=subproc.download_and_install_package,
args=(self.pipe_subproc, package, install_path)) args=(self.pipe_subproc, package, install_path))
return proc return proc
@@ -356,7 +357,7 @@ class PACKAGE_OT_uninstall(SubprocMixin, bpy.types.Operator):
global _packages global _packages
package = _packages[self.package_name].get_latest_version() package = _packages[self.package_name].get_latest_version()
proc = multiprocessing.Process(target=subproc.uninstall_package, proc = mp_context.Process(target=subproc.uninstall_package,
args=(self.pipe_subproc, package, install_path)) args=(self.pipe_subproc, package, install_path))
return proc return proc
@@ -465,7 +466,7 @@ class PACKAGE_OT_refresh_repositories(SubprocMixin, bpy.types.Operator):
storage_path = pathlib.Path(bpy.utils.user_resource('CONFIG', 'packages', create=True)) storage_path = pathlib.Path(bpy.utils.user_resource('CONFIG', 'packages', create=True))
repository_url = self.repolist[0].url repository_url = self.repolist[0].url
proc = multiprocessing.Process(target=subproc.refresh_repository, proc = mp_context.Process(target=subproc.refresh_repository,
args=(self.pipe_subproc, storage_path, repository_url)) args=(self.pipe_subproc, storage_path, repository_url))
return proc return proc