From 19c6181968d12dc01399e92a51c4cef7aeff4ab9 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 11 Mar 2021 10:05:18 +0100 Subject: [PATCH 1/5] removed set_environments function as it is --- start.py | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/start.py b/start.py index bb6e7a90be..74cf4772d0 100644 --- a/start.py +++ b/start.py @@ -112,46 +112,13 @@ if getattr(sys, 'frozen', False): os.environ["PYTHONPATH"] = os.pathsep.join(paths) from igniter import BootstrapRepos # noqa: E402 -from igniter.tools import load_environments, get_pype_path_from_db # noqa +from igniter.tools import get_pype_path_from_db # noqa from igniter.bootstrap_repos import PypeVersion # noqa: E402 bootstrap = BootstrapRepos() silent_commands = ["run", "igniter", "standalonepublisher"] -def set_environments() -> None: - """Set loaded environments. - - .. todo: - better handling of environments - - """ - try: - import acre - except ImportError: - if getattr(sys, 'frozen', False): - sys.path.append(os.path.join( - os.path.dirname(sys.executable), - "dependencies" - )) - try: - import acre - except ImportError as e: - # giving up - print("!!! cannot import acre") - print(f"{e}") - sys.exit(1) - try: - env = load_environments(["global"]) - except OSError as e: - print(f"!!! {e}") - sys.exit(1) - - # acre must be available here - env = acre.merge(env, dict(os.environ)) # noqa - os.environ.clear() - os.environ.update(env) - def run(arguments: list, env: dict = None) -> int: """Use correct executable to run stuff. @@ -573,9 +540,6 @@ def boot(): else: os.environ["PYPE_ROOT"] = os.path.dirname(__file__) - # No environment loading from settings until Pype version is established. - # set_environments() - # Get Pype path from database and set it to environment so Pype can # find its versions there and bootstrap them. pype_path = get_pype_path_from_db(pype_mongo) From 11a0be709c251c7273d8a4d0ae40cbc306f4c5f7 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 11 Mar 2021 10:09:59 +0100 Subject: [PATCH 2/5] added set_pype_global_environments which set environments from general and few hardcoded values --- start.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/start.py b/start.py index 74cf4772d0..b5e0fee847 100644 --- a/start.py +++ b/start.py @@ -119,6 +119,26 @@ bootstrap = BootstrapRepos() silent_commands = ["run", "igniter", "standalonepublisher"] +def set_pype_global_environments() -> None: + """Set global pype's environments.""" + import acre + + from pype.settings import get_environments + + all_env = get_environments() + + # TODO Global environments will be stored in "general" settings so loading + # will be modified and can be done in igniter. + env = acre.merge(all_env["global"], dict(os.environ)) + os.environ.clear() + os.environ.update(env) + + # Hardcoded default values + os.environ["PYBLISH_GUI"] = "pyblish_pype" + # Change scale factor only if is not set + if "QT_AUTO_SCREEN_SCALE_FACTOR" not in os.environ: + os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" + def run(arguments: list, env: dict = None) -> int: """Use correct executable to run stuff. @@ -591,9 +611,11 @@ def boot(): from pype.lib import terminal as t from pype.version import __version__ print(">>> loading environments ...") - # Must happen before `set_modules_environments` + # Avalon environments must be set before avalon module is imported print(" - for Avalon ...") set_avalon_environments() + print(" - global Pype ...") + set_pype_global_environments() print(" - for modules ...") set_modules_environments() From 68540073fa93dfe5506b9d424c89b28e726c47b8 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 11 Mar 2021 10:16:24 +0100 Subject: [PATCH 3/5] removed al,ready hardcoded environments form defaults --- pype/settings/defaults/system_settings/general.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pype/settings/defaults/system_settings/general.json b/pype/settings/defaults/system_settings/general.json index db20be420f..35b450feee 100644 --- a/pype/settings/defaults/system_settings/general.json +++ b/pype/settings/defaults/system_settings/general.json @@ -23,15 +23,11 @@ "darwin": "{VIRTUAL_ENV}/bin/python" }, "PYPE_OCIO_CONFIG": "{STUDIO_SOFT}/OpenColorIO-Configs", - "PYBLISH_GUI": "pyblish_pype", - "QT_AUTO_SCREEN_SCALE_FACTOR": "1", "__environment_keys__": { "global": [ "FFMPEG_PATH", "PYPE_PYTHON_EXE", - "PYPE_OCIO_CONFIG", - "PYBLISH_GUI", - "QT_AUTO_SCREEN_SCALE_FACTOR" + "PYPE_OCIO_CONFIG" ] } } From fe09a88db36c64305a758a6e4a96b5dde7972f0e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 11 Mar 2021 10:17:48 +0100 Subject: [PATCH 4/5] removed PYPE_PYTHON_EXE from global environments --- pype/settings/defaults/system_settings/general.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pype/settings/defaults/system_settings/general.json b/pype/settings/defaults/system_settings/general.json index 35b450feee..bf2bb5def0 100644 --- a/pype/settings/defaults/system_settings/general.json +++ b/pype/settings/defaults/system_settings/general.json @@ -17,16 +17,10 @@ "darwin": "{PYPE_ROOT}/vendor/bin/ffmpeg_exec/darwin/bin", "linux": ":{PYPE_ROOT}/vendor/bin/ffmpeg_exec/linux" }, - "PYPE_PYTHON_EXE": { - "windows": "{VIRTUAL_ENV}/Scripts/python.exe", - "linux": "{VIRTUAL_ENV}/Scripts/python", - "darwin": "{VIRTUAL_ENV}/bin/python" - }, "PYPE_OCIO_CONFIG": "{STUDIO_SOFT}/OpenColorIO-Configs", "__environment_keys__": { "global": [ "FFMPEG_PATH", - "PYPE_PYTHON_EXE", "PYPE_OCIO_CONFIG" ] } From fe80ad7032ce06bee0cf509f22ee429d0f3aa4b2 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 11 Mar 2021 10:59:05 +0100 Subject: [PATCH 5/5] modified tvpaint's prelaunch hook to not use PYPE_PYTHON_EXE --- pype/hosts/tvpaint/hooks/pre_launch_args.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pype/hosts/tvpaint/hooks/pre_launch_args.py b/pype/hosts/tvpaint/hooks/pre_launch_args.py index ebb911220f..2bba9c950f 100644 --- a/pype/hosts/tvpaint/hooks/pre_launch_args.py +++ b/pype/hosts/tvpaint/hooks/pre_launch_args.py @@ -2,7 +2,10 @@ import os import shutil from pype.hosts import tvpaint -from pype.lib import PreLaunchHook +from pype.lib import ( + PreLaunchHook, + get_pype_execute_args +) import avalon @@ -20,18 +23,16 @@ class TvpaintPrelaunchHook(PreLaunchHook): def execute(self): # Pop tvpaint executable - tvpaint_executable = self.launch_context.launch_args.pop(0) + executable_path = self.launch_context.launch_args.pop(0) # Pop rest of launch arguments - There should not be other arguments! remainders = [] while self.launch_context.launch_args: remainders.append(self.launch_context.launch_args.pop(0)) - new_launch_args = [ - self.main_executable(), - self.launch_script_path(), - tvpaint_executable - ] + new_launch_args = get_pype_execute_args( + "run", self.launch_script_path(), executable_path + ) # Add workfile to launch arguments workfile_path = self.workfile_path() @@ -56,11 +57,6 @@ class TvpaintPrelaunchHook(PreLaunchHook): ).format(str(remainders))) self.launch_context.launch_args.extend(remainders) - def main_executable(self): - """Should lead to python executable.""" - # TODO change in Pype 3 - return os.path.normpath(os.environ["PYPE_PYTHON_EXE"]) - def launch_script_path(self): avalon_dir = os.path.dirname(os.path.abspath(avalon.__file__)) script_path = os.path.join(