Compare commits
12 Commits
fix-replic
...
v0.5.8
Author | SHA1 | Date | |
---|---|---|---|
12355b6457 | |||
74ad4e5e1f | |||
2a88c3e5ac | |||
757ee7015a | |||
4dc6781c94 | |||
5e929db3ee | |||
0c60c86775 | |||
6efd1321ce | |||
4b7573234a | |||
ac84509b83 | |||
69565b3852 | |||
57fdd492ef |
@ -1,5 +1,13 @@
|
|||||||
stages:
|
stages:
|
||||||
|
- test
|
||||||
- build
|
- build
|
||||||
|
- deploy
|
||||||
|
- doc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
include:
|
include:
|
||||||
|
- local: .gitlab/ci/test.gitlab-ci.yml
|
||||||
- local: .gitlab/ci/build.gitlab-ci.yml
|
- local: .gitlab/ci/build.gitlab-ci.yml
|
||||||
|
- local: .gitlab/ci/deploy.gitlab-ci.yml
|
||||||
|
- local: .gitlab/ci/doc.gitlab-ci.yml
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
needs: ["test"]
|
||||||
image: debian:stable-slim
|
image: debian:stable-slim
|
||||||
script:
|
script:
|
||||||
- rm -rf tests .git .gitignore script
|
- rm -rf tests .git .gitignore script
|
||||||
|
@ -26,8 +26,8 @@ import numpy as np
|
|||||||
BPY_TO_NUMPY_TYPES = {
|
BPY_TO_NUMPY_TYPES = {
|
||||||
'FLOAT': np.float32,
|
'FLOAT': np.float32,
|
||||||
'INT': np.int32,
|
'INT': np.int32,
|
||||||
'BOOL': np.bool,
|
'BOOL': bool,
|
||||||
'BOOLEAN': np.bool}
|
'BOOLEAN': bool}
|
||||||
|
|
||||||
PRIMITIVE_TYPES = ['FLOAT', 'INT', 'BOOLEAN']
|
PRIMITIVE_TYPES = ['FLOAT', 'INT', 'BOOLEAN']
|
||||||
|
|
||||||
|
@ -30,14 +30,12 @@ VERSION_EXPR = re.compile('\d+.\d+.\d+')
|
|||||||
DEFAULT_CACHE_DIR = os.path.join(
|
DEFAULT_CACHE_DIR = os.path.join(
|
||||||
os.path.dirname(os.path.abspath(__file__)), "cache")
|
os.path.dirname(os.path.abspath(__file__)), "cache")
|
||||||
REPLICATION_DEPENDENCIES = {
|
REPLICATION_DEPENDENCIES = {
|
||||||
("pyzmq", "25.0.0"),
|
"zmq",
|
||||||
("deepdiff","5.7.0"),
|
"deepdiff"
|
||||||
}
|
}
|
||||||
LIBS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "libs")
|
LIBS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "libs")
|
||||||
REPLICATION = os.path.join(LIBS,"replication")
|
REPLICATION = os.path.join(LIBS,"replication")
|
||||||
|
|
||||||
PYTHON_PATH = None
|
|
||||||
SUBPROCESS_DIR = None
|
|
||||||
|
|
||||||
rtypes = []
|
rtypes = []
|
||||||
|
|
||||||
@ -50,13 +48,13 @@ def module_can_be_imported(name: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def install_pip():
|
def install_pip(python_path):
|
||||||
# pip can not necessarily be imported into Blender after this
|
# 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, version:str=None, install_dir: str=None):
|
def install_requirements(python_path:str, module_requirement: str, install_dir: str):
|
||||||
logging.info(f"installing {name} version...")
|
logging.info(f"Installing {module_requirement} dependencies in {install_dir}")
|
||||||
env = os.environ
|
env = os.environ
|
||||||
if "PIP_REQUIRE_VIRTUALENV" in env:
|
if "PIP_REQUIRE_VIRTUALENV" in env:
|
||||||
# PIP_REQUIRE_VIRTUALENV is an env var to ensure pip cannot install packages outside a virtual env
|
# PIP_REQUIRE_VIRTUALENV is an env var to ensure pip cannot install packages outside a virtual env
|
||||||
@ -65,24 +63,7 @@ def install_package(name: str, version:str=None, install_dir: str=None):
|
|||||||
# env var for the subprocess.
|
# env var for the subprocess.
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
del env["PIP_REQUIRE_VIRTUALENV"]
|
del env["PIP_REQUIRE_VIRTUALENV"]
|
||||||
module_name = f"{name}" if version is None else f"{name}=={version}"
|
subprocess.run([str(python_path), "-m", "pip", "install", "-r", f"{install_dir}/{module_requirement}/requirements.txt", "-t", install_dir], env=env)
|
||||||
subprocess.run([str(PYTHON_PATH), "-m", "pip", "install", module_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
|
|
||||||
|
|
||||||
|
|
||||||
def get_ip():
|
def get_ip():
|
||||||
@ -120,32 +101,27 @@ def remove_paths(paths: list):
|
|||||||
sys.path.remove(path)
|
sys.path.remove(path)
|
||||||
|
|
||||||
|
|
||||||
def install_modules(dependencies: tuple, 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, package_version in dependencies:
|
|
||||||
if not module_can_be_imported(package_name):
|
|
||||||
install_package(package_name, version=package_version, install_dir=install_dir)
|
|
||||||
module_can_be_imported(package_name)
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
if bpy.app.version >= (2,91,0):
|
if bpy.app.version >= (2,91,0):
|
||||||
python_binary_path = sys.executable
|
python_binary_path = sys.executable
|
||||||
else:
|
else:
|
||||||
python_binary_path = bpy.app.binary_path_python
|
python_binary_path = bpy.app.binary_path_python
|
||||||
|
|
||||||
|
python_path = Path(python_binary_path)
|
||||||
|
|
||||||
for module_name in list(sys.modules.keys()):
|
for module_name in list(sys.modules.keys()):
|
||||||
if 'replication' in module_name:
|
if 'replication' in module_name:
|
||||||
del sys.modules[module_name]
|
del sys.modules[module_name]
|
||||||
|
|
||||||
setup_paths([LIBS, REPLICATION])
|
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():
|
def unregister():
|
||||||
remove_paths([REPLICATION, LIBS])
|
remove_paths([REPLICATION, LIBS])
|
@ -133,7 +133,7 @@ def load_pre_handler(dummy):
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def update_client_frame(scene):
|
def update_client_frame(scene):
|
||||||
if session and session.state == STATE_ACTIVE and bpy.context.screen and not bpy.context.screen.is_animation_playing:
|
if session and session.state == STATE_ACTIVE:
|
||||||
porcelain.update_user_metadata(session.repository, {
|
porcelain.update_user_metadata(session.repository, {
|
||||||
'frame_current': scene.frame_current
|
'frame_current': scene.frame_current
|
||||||
})
|
})
|
||||||
|
Submodule multi_user/libs/replication updated: b60feead9d...3e9eb4f5c0
@ -297,20 +297,17 @@ def setup_timer():
|
|||||||
session_user_sync = timers.SessionUserSync()
|
session_user_sync = timers.SessionUserSync()
|
||||||
session_background_executor = timers.MainThreadExecutor(execution_queue=background_execution_queue)
|
session_background_executor = timers.MainThreadExecutor(execution_queue=background_execution_queue)
|
||||||
session_listen = timers.SessionListenTimer(timeout=0.001)
|
session_listen = timers.SessionListenTimer(timeout=0.001)
|
||||||
session_frame_sync = timers.SessionFrameSync(timeout=1)
|
|
||||||
|
|
||||||
session_listen.register()
|
session_listen.register()
|
||||||
session_update.register()
|
session_update.register()
|
||||||
session_user_sync.register()
|
session_user_sync.register()
|
||||||
session_background_executor.register()
|
session_background_executor.register()
|
||||||
session_frame_sync.register()
|
|
||||||
|
|
||||||
deleyables.append(session_background_executor)
|
deleyables.append(session_background_executor)
|
||||||
deleyables.append(session_update)
|
deleyables.append(session_update)
|
||||||
deleyables.append(session_user_sync)
|
deleyables.append(session_user_sync)
|
||||||
deleyables.append(session_listen)
|
deleyables.append(session_listen)
|
||||||
deleyables.append(timers.AnnotationUpdates())
|
deleyables.append(timers.AnnotationUpdates())
|
||||||
deleyables.append(session_frame_sync)
|
|
||||||
|
|
||||||
def get_active_server_preset(context):
|
def get_active_server_preset(context):
|
||||||
active_index = context.window_manager.server_index
|
active_index = context.window_manager.server_index
|
||||||
|
@ -44,27 +44,6 @@ DEFAULT_PRESETS = {
|
|||||||
"admin_password": "admin",
|
"admin_password": "admin",
|
||||||
"server_password": ""
|
"server_password": ""
|
||||||
},
|
},
|
||||||
"NTHU Session 1" : {
|
|
||||||
"server_name": "Session 1",
|
|
||||||
"ip": "31.38.153.178",
|
|
||||||
"port": 5555,
|
|
||||||
"admin_password": "",
|
|
||||||
"server_password": ""
|
|
||||||
},
|
|
||||||
"NTHU Session 2" : {
|
|
||||||
"server_name": "Session 2",
|
|
||||||
"ip": "31.38.153.178",
|
|
||||||
"port": 5655,
|
|
||||||
"admin_password": "",
|
|
||||||
"server_password": ""
|
|
||||||
},
|
|
||||||
"NTHU Session 3" : {
|
|
||||||
"server_name": "Session 3",
|
|
||||||
"ip": "31.38.153.178",
|
|
||||||
"port": 5755,
|
|
||||||
"admin_password": "",
|
|
||||||
"server_password": ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def randomColor():
|
def randomColor():
|
||||||
|
@ -177,7 +177,6 @@ class AnnotationUpdates(Timer):
|
|||||||
affect_dependencies=False)
|
affect_dependencies=False)
|
||||||
self._annotating = False
|
self._annotating = False
|
||||||
|
|
||||||
|
|
||||||
class DynamicRightSelectTimer(Timer):
|
class DynamicRightSelectTimer(Timer):
|
||||||
def __init__(self, timeout=.1):
|
def __init__(self, timeout=.1):
|
||||||
super().__init__(timeout)
|
super().__init__(timeout)
|
||||||
@ -267,7 +266,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
|
|
||||||
class ClientUpdate(Timer):
|
class ClientUpdate(Timer):
|
||||||
def __init__(self, timeout=1):
|
def __init__(self, timeout=.1):
|
||||||
super().__init__(timeout)
|
super().__init__(timeout)
|
||||||
self.handle_quit = False
|
self.handle_quit = False
|
||||||
self.users_metadata = {}
|
self.users_metadata = {}
|
||||||
@ -388,12 +387,3 @@ class MainThreadExecutor(Timer):
|
|||||||
function, kwargs = self.execution_queue.get()
|
function, kwargs = self.execution_queue.get()
|
||||||
logging.debug(f"Executing {function.__name__}")
|
logging.debug(f"Executing {function.__name__}")
|
||||||
function(**kwargs)
|
function(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SessionFrameSync(Timer):
|
|
||||||
def execute(self):
|
|
||||||
if session and session.state == STATE_ACTIVE:
|
|
||||||
if bpy.context.screen and bpy.context.screen.is_animation_playing:
|
|
||||||
porcelain.update_user_metadata(session.repository, {
|
|
||||||
'frame_current': bpy.context.scene.frame_current
|
|
||||||
})
|
|
Reference in New Issue
Block a user