From 4c42a5be923728ea2fe9b26431c556a1fe051fa6 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Thu, 18 Aug 2022 21:40:07 +0200 Subject: [PATCH 1/3] fix: freeze deepdiff version in replication --- multi_user/libs/replication | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multi_user/libs/replication b/multi_user/libs/replication index d722cf0..b60feea 160000 --- a/multi_user/libs/replication +++ b/multi_user/libs/replication @@ -1 +1 @@ -Subproject commit d722cf0d65568b436d61d139cea42da000c5fea9 +Subproject commit b60feead9d30c0888767fa9ad1df21a40b89c05f From 2a88c3e5ac106f9279ee0b3dfcffcdfed9a24390 Mon Sep 17 00:00:00 2001 From: Swann Date: Thu, 6 Apr 2023 09:26:29 +0200 Subject: [PATCH 2/3] feat: use requirement to install dependencies fix: _bool numpy not found --- multi_user/bl_types/dump_anything.py | 4 +- multi_user/environment.py | 57 +++++++++------------------- multi_user/libs/replication | 2 +- multi_user/preferences.py | 7 ---- 4 files changed, 20 insertions(+), 50 deletions(-) diff --git a/multi_user/bl_types/dump_anything.py b/multi_user/bl_types/dump_anything.py index 3da447c..0c29e84 100644 --- a/multi_user/bl_types/dump_anything.py +++ b/multi_user/bl_types/dump_anything.py @@ -26,8 +26,8 @@ import numpy as np BPY_TO_NUMPY_TYPES = { 'FLOAT': np.float32, 'INT': np.int32, - 'BOOL': np.bool, - 'BOOLEAN': np.bool} + 'BOOL': bool, + 'BOOLEAN': bool} PRIMITIVE_TYPES = ['FLOAT', 'INT', 'BOOLEAN'] diff --git a/multi_user/environment.py b/multi_user/environment.py index 79e57cc..34eb71d 100644 --- a/multi_user/environment.py +++ b/multi_user/environment.py @@ -31,13 +31,11 @@ DEFAULT_CACHE_DIR = os.path.join( os.path.dirname(os.path.abspath(__file__)), "cache") REPLICATION_DEPENDENCIES = { "zmq", - "deepdiff==5.7.0" + "deepdiff" } LIBS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "libs") REPLICATION = os.path.join(LIBS,"replication") -PYTHON_PATH = None -SUBPROCESS_DIR = None rtypes = [] @@ -50,13 +48,13 @@ def module_can_be_imported(name: str) -> bool: return False -def install_pip(): +def install_pip(python_path): # pip can not necessarily be imported into Blender after this - subprocess.run([str(PYTHON_PATH), "-m", "ensurepip"]) + subprocess.run([str(python_path), "-m", "ensurepip"]) -def install_package(name: str, install_dir: str): - logging.info(f"installing {name} version...") +def install_requirements(python_path:str, module_requirement: str, install_dir: str): + logging.info(f"Installing {module_requirement} dependencies in {install_dir}") env = os.environ if "PIP_REQUIRE_VIRTUALENV" in env: # PIP_REQUIRE_VIRTUALENV is an env var to ensure pip cannot install packages outside a virtual env @@ -65,23 +63,7 @@ def install_package(name: str, install_dir: str): # env var for the subprocess. env = os.environ.copy() del env["PIP_REQUIRE_VIRTUALENV"] - subprocess.run([str(PYTHON_PATH), "-m", "pip", "install", f"{name}", "-t", install_dir], env=env) - - if name in sys.modules: - del sys.modules[name] - - -def check_package_version(name: str, required_version: str): - logging.info(f"Checking {name} version...") - out = subprocess.run([str(PYTHON_PATH), "-m", "pip", "show", name], capture_output=True) - - version = VERSION_EXPR.search(out.stdout.decode()) - if version and version.group() == required_version: - logging.info(f"{name} is up to date") - return True - else: - logging.info(f"{name} need an update") - return False + subprocess.run([str(python_path), "-m", "pip", "install", "-r", f"{install_dir}/{module_requirement}/requirements.txt", "-t", install_dir], env=env) def get_ip(): @@ -117,21 +99,7 @@ def remove_paths(paths: list): if path in sys.path: logging.debug(f"Removing {path} dir from the path.") sys.path.remove(path) - - -def install_modules(dependencies: list, python_path: str, install_dir: str): - global PYTHON_PATH, SUBPROCESS_DIR - - PYTHON_PATH = Path(python_path) - SUBPROCESS_DIR = PYTHON_PATH.parent - - if not module_can_be_imported("pip"): - install_pip() - - for package_name in dependencies: - if not module_can_be_imported(package_name): - install_package(package_name, install_dir=install_dir) - module_can_be_imported(package_name) + def register(): if bpy.app.version >= (2,91,0): @@ -139,12 +107,21 @@ def register(): else: python_binary_path = bpy.app.binary_path_python + python_path = Path(python_binary_path) + for module_name in list(sys.modules.keys()): if 'replication' in module_name: del sys.modules[module_name] setup_paths([LIBS, REPLICATION]) - install_modules(REPLICATION_DEPENDENCIES, python_binary_path, install_dir=LIBS) + + if not module_can_be_imported("pip"): + install_pip(python_path) + + deps_not_installed = [package_name for package_name in REPLICATION_DEPENDENCIES if not module_can_be_imported(package_name)] + if any(deps_not_installed): + install_requirements(python_path, module_requirement='replication', install_dir=LIBS) + def unregister(): remove_paths([REPLICATION, LIBS]) \ No newline at end of file diff --git a/multi_user/libs/replication b/multi_user/libs/replication index b60feea..3e9eb4f 160000 --- a/multi_user/libs/replication +++ b/multi_user/libs/replication @@ -1 +1 @@ -Subproject commit b60feead9d30c0888767fa9ad1df21a40b89c05f +Subproject commit 3e9eb4f5c052177c2fe1e16ff5d1f042456c30d0 diff --git a/multi_user/preferences.py b/multi_user/preferences.py index b41b0c8..3e5f80c 100644 --- a/multi_user/preferences.py +++ b/multi_user/preferences.py @@ -44,13 +44,6 @@ DEFAULT_PRESETS = { "admin_password": "admin", "server_password": "" }, - "public session" : { - "server_name": "public session", - "ip": "51.75.71.183", - "port": 5555, - "admin_password": "", - "server_password": "" - }, } def randomColor(): From 74ad4e5e1f0d1ed045dd27061eb413e13c82e11c Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Tue, 11 Apr 2023 12:43:52 +0000 Subject: [PATCH 3/3] fix: bump add-on version to 0.5.8 --- multi_user/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multi_user/__init__.py b/multi_user/__init__.py index 82b9f4d..861ad43 100644 --- a/multi_user/__init__.py +++ b/multi_user/__init__.py @@ -19,7 +19,7 @@ bl_info = { "name": "Multi-User", "author": "Swann Martinez", - "version": (0, 5, 7), + "version": (0, 5, 8), "description": "Enable real-time collaborative workflow inside blender", "blender": (2, 82, 0), "location": "3D View > Sidebar > Multi-User tab",