feat(general) : zmq auto config
This commit is contained in:
parent
c0b7f34b76
commit
385d416e6c
17
__init__.py
17
__init__.py
@ -12,7 +12,24 @@ bl_info = {
|
||||
import bpy
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import bpy
|
||||
import addon_utils
|
||||
from pathlib import Path
|
||||
|
||||
python_path = Path(bpy.app.binary_path_python)
|
||||
cwd_for_subprocesses = python_path.parent
|
||||
|
||||
def get_package_install_directory():
|
||||
for path in sys.path:
|
||||
if os.path.basename(path) in ("dist-packages", "site-packages"):
|
||||
return path
|
||||
|
||||
try:
|
||||
import zmq
|
||||
except:
|
||||
target = get_package_install_directory()
|
||||
subprocess.run([str(python_path), "-m", "pip", "install", "zmq", '--target', target], cwd=cwd_for_subprocesses)
|
||||
|
||||
from . import operators
|
||||
from . import ui
|
||||
|
@ -9,9 +9,10 @@ import threading
|
||||
import time
|
||||
from enum import Enum
|
||||
from random import randint
|
||||
import zmq
|
||||
|
||||
from . import draw, helpers, message
|
||||
from .libs import dump_anything, umsgpack, zmq
|
||||
from .libs import dump_anything, umsgpack
|
||||
|
||||
# import zmq
|
||||
lock = threading.Lock()
|
||||
|
@ -1,11 +1,12 @@
|
||||
import logging
|
||||
try:
|
||||
from .libs import umsgpack
|
||||
from .libs import zmq
|
||||
|
||||
except:
|
||||
# Server import
|
||||
from libs import umsgpack
|
||||
from libs import zmq
|
||||
|
||||
import zmq
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
@ -15,6 +15,9 @@ import gpu
|
||||
import mathutils
|
||||
from bpy_extras import view3d_utils
|
||||
from gpu_extras.batch import batch_for_shader
|
||||
from pathlib import Path
|
||||
|
||||
python_path = Path(bpy.app.binary_path_python)
|
||||
|
||||
from . import client, draw, helpers, ui
|
||||
from .libs import umsgpack
|
||||
@ -299,8 +302,9 @@ class session_create(bpy.types.Operator):
|
||||
global client_instance
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
print(python_path)
|
||||
server = subprocess.Popen(
|
||||
['python', 'server.py'], shell=False, stdout=subprocess.PIPE)
|
||||
[str(python_path), 'server.py'], shell=False, stdout=subprocess.PIPE)
|
||||
# time.sleep(0.1)
|
||||
|
||||
bpy.ops.session.join()
|
||||
|
Loading…
x
Reference in New Issue
Block a user