From 370ac65e1eadfb7667ad3ae6c0ef578b0d44c2f8 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 09:36:41 +0000 Subject: [PATCH 01/15] Create draft PR for #1405 From 384d8a9c170a9e0a286d3931f17bd0da4e0a7514 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 12:11:27 +0200 Subject: [PATCH 02/15] host implementation may have `add_implementation_envs` function in openpype.hosts. --- openpype/lib/applications.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index c5c192f51b..29cec57c4f 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1089,7 +1089,22 @@ def prepare_host_environments(data): # Merge dictionaries env_values = _merge_env(tool_env, env_values) - final_env = _merge_env(acre.compute(env_values), data["env"]) + loaded_env = _merge_env(acre.compute(env_values), data["env"]) + + final_env = None + if app.host_name: + module = __import__("openpype.hosts", fromlist=[app.host_name]) + host_module = getattr(module, app.host_name, None) + add_implementation_envs = None + if host_module: + add_implementation_envs = getattr( + host_module, "add_implementation_envs", None + ) + if add_implementation_envs: + final_env = add_implementation_envs(loaded_env) + + if final_env is None: + final_env = loaded_env # Update env data["env"].update(final_env) From a3e89486ad323c4afef3d44210ac899645a4fdf0 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 12:11:38 +0200 Subject: [PATCH 03/15] small cleanup --- openpype/lib/applications.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index 29cec57c4f..83f11a6b07 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -3,7 +3,6 @@ import re import copy import json import platform -import getpass import collections import inspect import subprocess @@ -362,7 +361,6 @@ class ApplicationManager: context = ApplicationLaunchContext( app, executable, **data ) - # TODO pass context through launch hooks return context.launch() @@ -626,7 +624,7 @@ class ApplicationLaunchContext: # Logger logger_name = "{}-{}".format(self.__class__.__name__, self.app_name) - self.log = PypeLogger().get_logger(logger_name) + self.log = PypeLogger.get_logger(logger_name) self.executable = executable From f8f64b5a05198ddc2c4342f23aa908b6d520baa6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 12:20:49 +0200 Subject: [PATCH 04/15] prepare_host_environments can not add implementation environments --- openpype/lib/applications.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index 83f11a6b07..b95ba85fbe 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1031,7 +1031,7 @@ def _merge_env(env, current_env): return result -def prepare_host_environments(data): +def prepare_host_environments(data, implementation_envs=True): """Modify launch environments based on launched app and context. Args: @@ -1090,7 +1090,8 @@ def prepare_host_environments(data): loaded_env = _merge_env(acre.compute(env_values), data["env"]) final_env = None - if app.host_name: + # + if app.host_name and implementation_envs: module = __import__("openpype.hosts", fromlist=[app.host_name]) host_module = getattr(module, app.host_name, None) add_implementation_envs = None @@ -1099,6 +1100,7 @@ def prepare_host_environments(data): host_module, "add_implementation_envs", None ) if add_implementation_envs: + # Function may only modify passed dict without returning value final_env = add_implementation_envs(loaded_env) if final_env is None: From bf07cbf494e52be3f53dc542c84039256b36771d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:24:21 +0200 Subject: [PATCH 05/15] initial implementation of blender's add_implementation_envs --- openpype/hosts/blender/__init__.py | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/openpype/hosts/blender/__init__.py b/openpype/hosts/blender/__init__.py index e69de29bb2..1a81c3add1 100644 --- a/openpype/hosts/blender/__init__.py +++ b/openpype/hosts/blender/__init__.py @@ -0,0 +1,41 @@ +import os + + +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + # Prepare path to implementation script + implementation_user_script_path = os.path.join( + os.environ["OPENPYPE_REPOS_ROOT"], + "repos", + "avalon-core", + "setup", + "blender" + ) + + # Add blender implementation script path to PYTHONPATH + python_path = env.get("PYTHONPATH") or "" + python_path_parts = [ + path + for path in python_path.split(os.pathsep) + if path + ] + python_path_parts.insert(0, implementation_user_script_path) + env["PYTHONPATH"] = os.pathsep.join(python_path_parts) + + # Modify Blender user scripts path + blender_user_scripts = env.get("BLENDER_USER_SCRIPTS") or "" + previous_user_scripts = [] + for path in blender_user_scripts.split(os.pathsep): + if path and os.path.exists(path): + path = os.path.normpath(path) + if path != implementation_user_script_path: + previous_user_scripts.append(path) + + env["OPENPYPE_BLENDER_USER_SCRIPTS"] = os.pathsep.join( + previous_user_scripts + ) + env["BLENDER_USER_SCRIPTS"] = implementation_user_script_path + + # Define Qt binding if not defined + if not env.get("QT_PREFERRED_BINDING"): + env["QT_PREFERRED_BINDING"] = "PySide2" From eb70dbd62ae391e3123ceb1a8f5290ad5af0f818 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:34:08 +0200 Subject: [PATCH 06/15] removed blender's environments --- .../settings/defaults/system_settings/applications.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 63d6da4633..d439ae35d9 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -852,14 +852,7 @@ "label": "Blender", "icon": "{}/app_icons/blender.png", "host_name": "blender", - "environment": { - "BLENDER_USER_SCRIPTS": "{OPENPYPE_REPOS_ROOT}/repos/avalon-core/setup/blender", - "PYTHONPATH": [ - "{OPENPYPE_REPOS_ROOT}/repos/avalon-core/setup/blender", - "{PYTHONPATH}" - ], - "QT_PREFERRED_BINDING": "PySide2" - }, + "environment": {}, "variants": { "2-83": { "use_python_2": false, From ad9087e3983fb1d9ce7082d5459be8f181a2f971 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:36:13 +0200 Subject: [PATCH 07/15] add maya's environments to add_implementation_envs --- openpype/hosts/maya/__init__.py | 29 +++++++++++++++++++ .../system_settings/applications.json | 15 +--------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/openpype/hosts/maya/__init__.py b/openpype/hosts/maya/__init__.py index e69de29bb2..10a128583e 100644 --- a/openpype/hosts/maya/__init__.py +++ b/openpype/hosts/maya/__init__.py @@ -0,0 +1,29 @@ +import os + + +def add_implementation_envs(env): + # Add requirements to PYTHONPATH + pype_root = os.environ["OPENPYPE_REPOS_ROOT"] + new_python_path = os.pathsep.join([ + os.path.join(pype_root, "openpype", "hosts", "maya", "startup"), + os.path.join(pype_root, "repos", "avalon-core", "setup", "maya"), + os.path.join(pype_root, "tools", "mayalookassigner") + ]) + old_python_path = env.get("PYTHONPATH") + if old_python_path: + new_python_path = os.pathsep.join([new_python_path, old_python_path]) + env["PYTHONPATH"] = new_python_path + + # Set default values if are not already set via settings + defaults = { + "MAYA_DISABLE_CLIC_IPM": "Yes", + "MAYA_DISABLE_CIP": "Yes", + "MAYA_DISABLE_CER": "Yes", + "PYMEL_SKIP_MEL_INIT": "Yes", + "LC_ALL": "C", + "OPENPYPE_LOG_NO_COLORS": "Yes" + } + for key, value in defaults.items(): + if env.get(key): + continue + env[key] = value diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index d439ae35d9..2904530cad 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -4,20 +4,7 @@ "label": "Maya", "icon": "{}/app_icons/maya.png", "host_name": "maya", - "environment": { - "PYTHONPATH": [ - "{OPENPYPE_REPOS_ROOT}/openpype/hosts/maya/startup", - "{OPENPYPE_REPOS_ROOT}/repos/avalon-core/setup/maya", - "{OPENPYPE_REPOS_ROOT}/repos/maya-look-assigner", - "{PYTHONPATH}" - ], - "MAYA_DISABLE_CLIC_IPM": "Yes", - "MAYA_DISABLE_CIP": "Yes", - "MAYA_DISABLE_CER": "Yes", - "PYMEL_SKIP_MEL_INIT": "Yes", - "LC_ALL": "C", - "OPENPYPE_LOG_NO_COLORS": "Yes" - }, + "environment": {}, "variants": { "2022": { "use_python_2": false, From 46c603464f1fb04d7f310dd381fc284af67e489e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:46:07 +0200 Subject: [PATCH 08/15] skip duplicated python paths --- openpype/hosts/maya/__init__.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/maya/__init__.py b/openpype/hosts/maya/__init__.py index 10a128583e..43a1e6f7bf 100644 --- a/openpype/hosts/maya/__init__.py +++ b/openpype/hosts/maya/__init__.py @@ -4,15 +4,21 @@ import os def add_implementation_envs(env): # Add requirements to PYTHONPATH pype_root = os.environ["OPENPYPE_REPOS_ROOT"] - new_python_path = os.pathsep.join([ + new_python_paths = [ os.path.join(pype_root, "openpype", "hosts", "maya", "startup"), os.path.join(pype_root, "repos", "avalon-core", "setup", "maya"), os.path.join(pype_root, "tools", "mayalookassigner") - ]) - old_python_path = env.get("PYTHONPATH") - if old_python_path: - new_python_path = os.pathsep.join([new_python_path, old_python_path]) - env["PYTHONPATH"] = new_python_path + ] + old_python_path = env.get("PYTHONPATH") or "" + for path in old_python_path.split(os.pathsep): + if not path or not os.path.exists(path): + continue + + norm_path = os.path.normpath(path) + if norm_path not in new_python_paths: + new_python_paths.append(norm_path) + + env["PYTHONPATH"] = os.pathsep.join(new_python_paths) # Set default values if are not already set via settings defaults = { @@ -24,6 +30,5 @@ def add_implementation_envs(env): "OPENPYPE_LOG_NO_COLORS": "Yes" } for key, value in defaults.items(): - if env.get(key): - continue - env[key] = value + if not env.get(key): + env[key] = value From 5c366f2ee97a635e5db7b48dbec1ef5d25f701e7 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:46:25 +0200 Subject: [PATCH 09/15] implemented add_implementation_envs for nuke --- openpype/hosts/nuke/__init__.py | 42 +++++++++++++++++++ .../system_settings/applications.json | 10 +---- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/nuke/__init__.py b/openpype/hosts/nuke/__init__.py index e69de29bb2..901ee7c54c 100644 --- a/openpype/hosts/nuke/__init__.py +++ b/openpype/hosts/nuke/__init__.py @@ -0,0 +1,42 @@ +import os +import platform + + +def add_implementation_envs(env): + # Add requirements to NUKE_PATH + pype_root = os.environ["OPENPYPE_REPOS_ROOT"] + new_nuke_paths = [ + os.path.join(pype_root, "openpype", "hosts", "maya", "startup"), + os.path.join(pype_root, "repos", "avalon-core", "setup", "maya"), + os.path.join(pype_root, "tools", "mayalookassigner") + ] + old_nuke_path = env.get("NUKE_PATH") or "" + for path in old_nuke_path.split(os.pathsep): + if not path or not os.path.exists(path): + continue + + norm_path = os.path.normpath(path) + if norm_path not in new_nuke_paths: + new_nuke_paths.append(norm_path) + + env["NUKE_PATH"] = os.pathsep.join(new_nuke_paths) + + # Try to add QuickTime to PATH + quick_time_path = "C:/Program Files (x86)/QuickTime/QTSystem" + if platform.system() == "windows" and os.path.exists(quick_time_path): + path_value = env.get("PATH") or "" + path_paths = [ + path + for path in path_value.split(os.pathsep) + if path + ] + path_paths.append(quick_time_path) + env["PATH"] = os.pathsep.join(path_paths) + + # Set default values if are not already set via settings + defaults = { + "LOGLEVEL": "DEBUG" + } + for key, value in defaults.items(): + if not env.get(key): + env[key] = value diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 2904530cad..30c697ddeb 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -97,15 +97,7 @@ "icon": "{}/app_icons/nuke.png", "host_name": "nuke", "environment": { - "NUKE_PATH": [ - "{OPENPYPE_REPOS_ROOT}/repos/avalon-core/setup/nuke/nuke_path", - "{OPENPYPE_REPOS_ROOT}/openpype/hosts/nuke/startup", - "{OPENPYPE_STUDIO_PLUGINS}/nuke" - ], - "PATH": { - "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" - }, - "LOGLEVEL": "DEBUG" + "NUKE_PATH": "{OPENPYPE_STUDIO_PLUGINS}/nuke" }, "variants": { "13-0": { From 7bdc937f697c660361365422902ecc27cbb1848b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:50:50 +0200 Subject: [PATCH 10/15] fixed default paths in nuke host and removed defaults for nuke x --- openpype/hosts/nuke/__init__.py | 7 ++++--- .../defaults/system_settings/applications.json | 10 +--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/nuke/__init__.py b/openpype/hosts/nuke/__init__.py index 901ee7c54c..ca4d931e2c 100644 --- a/openpype/hosts/nuke/__init__.py +++ b/openpype/hosts/nuke/__init__.py @@ -6,9 +6,10 @@ def add_implementation_envs(env): # Add requirements to NUKE_PATH pype_root = os.environ["OPENPYPE_REPOS_ROOT"] new_nuke_paths = [ - os.path.join(pype_root, "openpype", "hosts", "maya", "startup"), - os.path.join(pype_root, "repos", "avalon-core", "setup", "maya"), - os.path.join(pype_root, "tools", "mayalookassigner") + os.path.join(pype_root, "openpype", "hosts", "nuke", "startup"), + os.path.join( + pype_root, "repos", "avalon-core", "setup", "nuke", "nuke_path" + ) ] old_nuke_path = env.get("NUKE_PATH") or "" for path in old_nuke_path.split(os.pathsep): diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 30c697ddeb..01602bf549 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -203,15 +203,7 @@ "icon": "{}/app_icons/nuke.png", "host_name": "nuke", "environment": { - "NUKE_PATH": [ - "{OPENPYPE_REPOS_ROOT}/repos/avalon-core/setup/nuke/nuke_path", - "{OPENPYPE_REPOS_ROOT}/openpype/hosts/nuke/startup", - "{OPENPYPE_STUDIO_PLUGINS}/nuke" - ], - "PATH": { - "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" - }, - "LOGLEVEL": "DEBUG" + "NUKE_PATH": "{OPENPYPE_STUDIO_PLUGINS}/nuke" }, "variants": { "13-0": { From 243de91a8ef6a0ee5862a86e43c3a0efce7d5d11 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:52:14 +0200 Subject: [PATCH 11/15] converted hiero and nukestudio environments to host defaults --- openpype/hosts/hiero/__init__.py | 40 +++++++++++++++++++ .../system_settings/applications.json | 18 +-------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/openpype/hosts/hiero/__init__.py b/openpype/hosts/hiero/__init__.py index e69de29bb2..5b036224e4 100644 --- a/openpype/hosts/hiero/__init__.py +++ b/openpype/hosts/hiero/__init__.py @@ -0,0 +1,40 @@ +import os +import platform + + +def add_implementation_envs(env): + # Add requirements to HIERO_PLUGIN_PATH + pype_root = os.environ["OPENPYPE_REPOS_ROOT"] + new_hiero_paths = [ + os.path.join(pype_root, "openpype", "hosts", "hiero", "startup") + ] + old_hiero_path = env.get("HIERO_PLUGIN_PATH") or "" + for path in old_hiero_path.split(os.pathsep): + if not path or not os.path.exists(path): + continue + + norm_path = os.path.normpath(path) + if norm_path not in new_hiero_paths: + new_hiero_paths.append(norm_path) + + env["HIERO_PLUGIN_PATH"] = os.pathsep.join(new_hiero_paths) + + # Try to add QuickTime to PATH + quick_time_path = "C:/Program Files (x86)/QuickTime/QTSystem" + if platform.system() == "windows" and os.path.exists(quick_time_path): + path_value = env.get("PATH") or "" + path_paths = [ + path + for path in path_value.split(os.pathsep) + if path + ] + path_paths.append(quick_time_path) + env["PATH"] = os.pathsep.join(path_paths) + + # Set default values if are not already set via settings + defaults = { + "LOGLEVEL": "DEBUG" + } + for key, value in defaults.items(): + if not env.get(key): + env[key] = value diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 01602bf549..486aa06849 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -339,15 +339,8 @@ "icon": "{}/app_icons/nuke.png", "host_name": "hiero", "environment": { - "HIERO_PLUGIN_PATH": [ - "{OPENPYPE_REPOS_ROOT}/openpype/hosts/hiero/startup" - ], - "PATH": { - "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" - }, "WORKFILES_STARTUP": "0", - "TAG_ASSETBUILD_STARTUP": "0", - "LOGLEVEL": "DEBUG" + "TAG_ASSETBUILD_STARTUP": "0" }, "variants": { "13-0": { @@ -481,15 +474,8 @@ "icon": "{}/app_icons/hiero.png", "host_name": "hiero", "environment": { - "HIERO_PLUGIN_PATH": [ - "{OPENPYPE_REPOS_ROOT}/openpype/hosts/hiero/startup" - ], - "PATH": { - "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" - }, "WORKFILES_STARTUP": "0", - "TAG_ASSETBUILD_STARTUP": "0", - "LOGLEVEL": "DEBUG" + "TAG_ASSETBUILD_STARTUP": "0" }, "variants": { "13-0": { From 65b308c7a54a96bf44c4e7062ff69e8e3ab64700 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 14:10:00 +0200 Subject: [PATCH 12/15] converted tvpaintconverted aftereffects harmony photoshop tvpaint and unreal to define default environments --- openpype/hosts/aftereffects/__init__.py | 9 +++++++++ openpype/hosts/harmony/__init__.py | 10 ++++++++++ openpype/hosts/photoshop/__init__.py | 9 +++++++++ openpype/hosts/tvpaint/__init__.py | 8 ++++++++ openpype/hosts/unreal/__init__.py | 18 ++++++++++++++++++ .../defaults/system_settings/applications.json | 16 +++------------- 6 files changed, 57 insertions(+), 13 deletions(-) diff --git a/openpype/hosts/aftereffects/__init__.py b/openpype/hosts/aftereffects/__init__.py index e69de29bb2..1c2d473728 100644 --- a/openpype/hosts/aftereffects/__init__.py +++ b/openpype/hosts/aftereffects/__init__.py @@ -0,0 +1,9 @@ +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + defaults = { + "OPENPYPE_LOG_NO_COLORS": "True", + "WEBSOCKET_URL": "ws://localhost:8097/ws/" + } + for key, value in defaults.items(): + if not env.get(key): + env[key] = value diff --git a/openpype/hosts/harmony/__init__.py b/openpype/hosts/harmony/__init__.py index e69de29bb2..13b72f98d6 100644 --- a/openpype/hosts/harmony/__init__.py +++ b/openpype/hosts/harmony/__init__.py @@ -0,0 +1,10 @@ +import os + + +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + openharmony_path = os.path.join( + os.environ["OPENPYPE_REPOS_ROOT"], "pype", "vendor", "OpenHarmony" + ) + # TODO check if is already set? What to do if is already set? + env["LIB_OPENHARMONY_PATH"] = openharmony_path diff --git a/openpype/hosts/photoshop/__init__.py b/openpype/hosts/photoshop/__init__.py index e69de29bb2..babacba9a8 100644 --- a/openpype/hosts/photoshop/__init__.py +++ b/openpype/hosts/photoshop/__init__.py @@ -0,0 +1,9 @@ +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + defaults = { + "OPENPYPE_LOG_NO_COLORS": "True", + "WEBSOCKET_URL": "ws://localhost:8099/ws/" + } + for key, value in defaults.items(): + if not env.get(key): + env[key] = value diff --git a/openpype/hosts/tvpaint/__init__.py b/openpype/hosts/tvpaint/__init__.py index e69de29bb2..0e58e31a5b 100644 --- a/openpype/hosts/tvpaint/__init__.py +++ b/openpype/hosts/tvpaint/__init__.py @@ -0,0 +1,8 @@ +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + defaults = { + "OPENPYPE_LOG_NO_COLORS": "True" + } + for key, value in defaults.items(): + if not env.get(key): + env[key] = value diff --git a/openpype/hosts/unreal/__init__.py b/openpype/hosts/unreal/__init__.py index e69de29bb2..dd7a575995 100644 --- a/openpype/hosts/unreal/__init__.py +++ b/openpype/hosts/unreal/__init__.py @@ -0,0 +1,18 @@ +import os + + +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + # Set AVALON_UNREAL_PLUGIN required for Unreal implementation + unreal_plugin_path = os.path.join( + os.environ["OPENPYPE_REPOS_ROOT"], "repos", "avalon-unreal-integration" + ) + env["AVALON_UNREAL_PLUGIN"] = unreal_plugin_path + + # Set default environments if are not set via settings + defaults = { + "OPENPYPE_LOG_NO_COLORS": "True" + } + for key, value in defaults.items(): + if not env.get(key): + env[key] = value diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 486aa06849..fd0a5b8c52 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -890,8 +890,7 @@ "icon": "{}/app_icons/harmony.png", "host_name": "harmony", "environment": { - "AVALON_HARMONY_WORKFILES_ON_LAUNCH": "1", - "LIB_OPENHARMONY_PATH": "{OPENPYPE_REPOS_ROOT}/pype/vendor/OpenHarmony" + "AVALON_HARMONY_WORKFILES_ON_LAUNCH": "1" }, "variants": { "20": { @@ -935,9 +934,7 @@ "label": "TVPaint", "icon": "{}/app_icons/tvpaint.png", "host_name": "tvpaint", - "environment": { - "OPENPYPE_LOG_NO_COLORS": "True" - }, + "environment": {}, "variants": { "animation_11-64bits": { "use_python_2": false, @@ -984,8 +981,6 @@ "host_name": "photoshop", "environment": { "AVALON_PHOTOSHOP_WORKFILES_ON_LAUNCH": "1", - "OPENPYPE_LOG_NO_COLORS": "Yes", - "WEBSOCKET_URL": "ws://localhost:8099/ws/", "WORKFILES_SAVE_AS": "Yes" }, "variants": { @@ -1034,8 +1029,6 @@ "host_name": "aftereffects", "environment": { "AVALON_AFTEREFFECTS_WORKFILES_ON_LAUNCH": "1", - "OPENPYPE_LOG_NO_COLORS": "Yes", - "WEBSOCKET_URL": "ws://localhost:8097/ws/", "WORKFILES_SAVE_AS": "Yes" }, "variants": { @@ -1109,10 +1102,7 @@ "label": "Unreal Editor", "icon": "{}/app_icons/ue4.png'", "host_name": "unreal", - "environment": { - "AVALON_UNREAL_PLUGIN": "{OPENPYPE_REPOS_ROOT}/repos/avalon-unreal-integration", - "OPENPYPE_LOG_NO_COLORS": "True" - }, + "environment": {}, "variants": { "4-26": { "use_python_2": false, From 6690f4a88c297f64c85ead174dcc28bc1cb77e21 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 14:10:19 +0200 Subject: [PATCH 13/15] houdini can define default environments --- openpype/hosts/houdini/__init__.py | 38 +++++++++++++++++++ .../system_settings/applications.json | 13 +------ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/houdini/__init__.py b/openpype/hosts/houdini/__init__.py index e69de29bb2..ab552513e8 100644 --- a/openpype/hosts/houdini/__init__.py +++ b/openpype/hosts/houdini/__init__.py @@ -0,0 +1,38 @@ +import os + + +def add_implementation_envs(env): + # Add requirements to HOUDINI_PATH and HOUDINI_MENU_PATH + pype_root = os.environ["OPENPYPE_REPOS_ROOT"] + + startup_path = os.path.join( + pype_root, "openpype", "hosts", "houdini", "startup" + ) + new_houdini_path = [startup_path] + new_houdini_menu_path = [startup_path] + + old_houdini_path = env.get("HOUDINI_PATH") or "" + old_houdini_menu_path = env.get("HOUDINI_MENU_PATH") or "" + + for path in old_houdini_path.split(os.pathsep): + if not path or not os.path.exists(path): + continue + + norm_path = os.path.normpath(path) + if norm_path not in new_houdini_path: + new_houdini_path.append(norm_path) + + for path in old_houdini_menu_path.split(os.pathsep): + if not path or not os.path.exists(path): + continue + + norm_path = os.path.normpath(path) + if norm_path not in new_houdini_menu_path: + new_houdini_menu_path.append(norm_path) + + # Add ampersand for unknown reason (Maybe is needed in Houdini?) + new_houdini_path.append("&") + new_houdini_menu_path.append("&") + + env["HOUDINI_PATH"] = os.pathsep.join(new_houdini_path) + env["HOUDINI_MENU_PATH"] = os.pathsep.join(new_houdini_menu_path) diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index fd0a5b8c52..d1976a9776 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -740,18 +740,7 @@ "label": "Houdini", "icon": "{}/app_icons/houdini.png", "host_name": "houdini", - "environment": { - "HOUDINI_PATH": { - "darwin": "{OPENPYPE_REPOS_ROOT}/openpype/hosts/houdini/startup:&", - "linux": "{OPENPYPE_REPOS_ROOT}/openpype/hosts/houdini/startup:&", - "windows": "{OPENPYPE_REPOS_ROOT}/openpype/hosts/houdini/startup;&" - }, - "HOUDINI_MENU_PATH": { - "darwin": "{OPENPYPE_REPOS_ROOT}/openpype/hosts/houdini/startup:&", - "linux": "{OPENPYPE_REPOS_ROOT}/openpype/hosts/houdini/startup:&", - "windows": "{OPENPYPE_REPOS_ROOT}/openpype/hosts/houdini/startup;&" - } - }, + "environment": {}, "variants": { "18-5": { "use_python_2": true, From d43b3d1b2c0e61a67587700400a7b4d89fcd5357 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 14:16:00 +0200 Subject: [PATCH 14/15] also pass Application object to `add_implementation_envs` --- openpype/hosts/aftereffects/__init__.py | 2 +- openpype/hosts/blender/__init__.py | 2 +- openpype/hosts/harmony/__init__.py | 2 +- openpype/hosts/hiero/__init__.py | 2 +- openpype/hosts/houdini/__init__.py | 2 +- openpype/hosts/maya/__init__.py | 2 +- openpype/hosts/nuke/__init__.py | 2 +- openpype/hosts/photoshop/__init__.py | 2 +- openpype/hosts/tvpaint/__init__.py | 2 +- openpype/hosts/unreal/__init__.py | 2 +- openpype/lib/applications.py | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/aftereffects/__init__.py b/openpype/hosts/aftereffects/__init__.py index 1c2d473728..deae48d122 100644 --- a/openpype/hosts/aftereffects/__init__.py +++ b/openpype/hosts/aftereffects/__init__.py @@ -1,4 +1,4 @@ -def add_implementation_envs(env): +def add_implementation_envs(env, _app): """Modify environments to contain all required for implementation.""" defaults = { "OPENPYPE_LOG_NO_COLORS": "True", diff --git a/openpype/hosts/blender/__init__.py b/openpype/hosts/blender/__init__.py index 1a81c3add1..4d93233449 100644 --- a/openpype/hosts/blender/__init__.py +++ b/openpype/hosts/blender/__init__.py @@ -1,7 +1,7 @@ import os -def add_implementation_envs(env): +def add_implementation_envs(env, _app): """Modify environments to contain all required for implementation.""" # Prepare path to implementation script implementation_user_script_path = os.path.join( diff --git a/openpype/hosts/harmony/__init__.py b/openpype/hosts/harmony/__init__.py index 13b72f98d6..8560fbaf4b 100644 --- a/openpype/hosts/harmony/__init__.py +++ b/openpype/hosts/harmony/__init__.py @@ -1,7 +1,7 @@ import os -def add_implementation_envs(env): +def add_implementation_envs(env, _app): """Modify environments to contain all required for implementation.""" openharmony_path = os.path.join( os.environ["OPENPYPE_REPOS_ROOT"], "pype", "vendor", "OpenHarmony" diff --git a/openpype/hosts/hiero/__init__.py b/openpype/hosts/hiero/__init__.py index 5b036224e4..1781f808e2 100644 --- a/openpype/hosts/hiero/__init__.py +++ b/openpype/hosts/hiero/__init__.py @@ -2,7 +2,7 @@ import os import platform -def add_implementation_envs(env): +def add_implementation_envs(env, _app): # Add requirements to HIERO_PLUGIN_PATH pype_root = os.environ["OPENPYPE_REPOS_ROOT"] new_hiero_paths = [ diff --git a/openpype/hosts/houdini/__init__.py b/openpype/hosts/houdini/__init__.py index ab552513e8..8c12d13c81 100644 --- a/openpype/hosts/houdini/__init__.py +++ b/openpype/hosts/houdini/__init__.py @@ -1,7 +1,7 @@ import os -def add_implementation_envs(env): +def add_implementation_envs(env, _app): # Add requirements to HOUDINI_PATH and HOUDINI_MENU_PATH pype_root = os.environ["OPENPYPE_REPOS_ROOT"] diff --git a/openpype/hosts/maya/__init__.py b/openpype/hosts/maya/__init__.py index 43a1e6f7bf..d3562e2cdd 100644 --- a/openpype/hosts/maya/__init__.py +++ b/openpype/hosts/maya/__init__.py @@ -1,7 +1,7 @@ import os -def add_implementation_envs(env): +def add_implementation_envs(env, _app): # Add requirements to PYTHONPATH pype_root = os.environ["OPENPYPE_REPOS_ROOT"] new_python_paths = [ diff --git a/openpype/hosts/nuke/__init__.py b/openpype/hosts/nuke/__init__.py index ca4d931e2c..f1e81617e0 100644 --- a/openpype/hosts/nuke/__init__.py +++ b/openpype/hosts/nuke/__init__.py @@ -2,7 +2,7 @@ import os import platform -def add_implementation_envs(env): +def add_implementation_envs(env, _app): # Add requirements to NUKE_PATH pype_root = os.environ["OPENPYPE_REPOS_ROOT"] new_nuke_paths = [ diff --git a/openpype/hosts/photoshop/__init__.py b/openpype/hosts/photoshop/__init__.py index babacba9a8..a91e0a65ff 100644 --- a/openpype/hosts/photoshop/__init__.py +++ b/openpype/hosts/photoshop/__init__.py @@ -1,4 +1,4 @@ -def add_implementation_envs(env): +def add_implementation_envs(env, _app): """Modify environments to contain all required for implementation.""" defaults = { "OPENPYPE_LOG_NO_COLORS": "True", diff --git a/openpype/hosts/tvpaint/__init__.py b/openpype/hosts/tvpaint/__init__.py index 0e58e31a5b..0e793fcf9f 100644 --- a/openpype/hosts/tvpaint/__init__.py +++ b/openpype/hosts/tvpaint/__init__.py @@ -1,4 +1,4 @@ -def add_implementation_envs(env): +def add_implementation_envs(env, _app): """Modify environments to contain all required for implementation.""" defaults = { "OPENPYPE_LOG_NO_COLORS": "True" diff --git a/openpype/hosts/unreal/__init__.py b/openpype/hosts/unreal/__init__.py index dd7a575995..1280442916 100644 --- a/openpype/hosts/unreal/__init__.py +++ b/openpype/hosts/unreal/__init__.py @@ -1,7 +1,7 @@ import os -def add_implementation_envs(env): +def add_implementation_envs(env, _app): """Modify environments to contain all required for implementation.""" # Set AVALON_UNREAL_PLUGIN required for Unreal implementation unreal_plugin_path = os.path.join( diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index b95ba85fbe..a44c43102f 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1090,7 +1090,7 @@ def prepare_host_environments(data, implementation_envs=True): loaded_env = _merge_env(acre.compute(env_values), data["env"]) final_env = None - # + # Add host specific environments if app.host_name and implementation_envs: module = __import__("openpype.hosts", fromlist=[app.host_name]) host_module = getattr(module, app.host_name, None) @@ -1101,7 +1101,7 @@ def prepare_host_environments(data, implementation_envs=True): ) if add_implementation_envs: # Function may only modify passed dict without returning value - final_env = add_implementation_envs(loaded_env) + final_env = add_implementation_envs(loaded_env, app) if final_env is None: final_env = loaded_env From 916d3457f5f016da75bc3553b038f30e14f4158d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 18:10:25 +0200 Subject: [PATCH 15/15] moved optional maya environments back to settings --- openpype/hosts/maya/__init__.py | 5 ----- .../settings/defaults/system_settings/applications.json | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/__init__.py b/openpype/hosts/maya/__init__.py index d3562e2cdd..549f100007 100644 --- a/openpype/hosts/maya/__init__.py +++ b/openpype/hosts/maya/__init__.py @@ -22,11 +22,6 @@ def add_implementation_envs(env, _app): # Set default values if are not already set via settings defaults = { - "MAYA_DISABLE_CLIC_IPM": "Yes", - "MAYA_DISABLE_CIP": "Yes", - "MAYA_DISABLE_CER": "Yes", - "PYMEL_SKIP_MEL_INIT": "Yes", - "LC_ALL": "C", "OPENPYPE_LOG_NO_COLORS": "Yes" } for key, value in defaults.items(): diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index d1976a9776..020924db67 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -4,7 +4,13 @@ "label": "Maya", "icon": "{}/app_icons/maya.png", "host_name": "maya", - "environment": {}, + "environment": { + "MAYA_DISABLE_CLIC_IPM": "Yes", + "MAYA_DISABLE_CIP": "Yes", + "MAYA_DISABLE_CER": "Yes", + "PYMEL_SKIP_MEL_INIT": "Yes", + "LC_ALL": "C" + }, "variants": { "2022": { "use_python_2": false,