diff --git a/app_launcher.py b/app_launcher.py index 2cb313742b..6dc1518370 100644 --- a/app_launcher.py +++ b/app_launcher.py @@ -29,16 +29,9 @@ def main(input_json_path): data = json.load(stream) # Change environment variables - # - environments that are in current environments and are not data are - # removed - if "env" in data: - env = data["env"] - # Pop environment variable keys that are not in source - for key in set(os.environ.keys()) - set(env.keys()): - os.environ.pop(key) - - for key, value in env.items(): - os.environ[key] = value + env = data.get("env") or {} + for key, value in env.items(): + os.environ[key] = value # Prepare launch arguments args = data["args"] diff --git a/openpype/hosts/nuke/__init__.py b/openpype/hosts/nuke/__init__.py index 4402d0b48e..60b37ce1dd 100644 --- a/openpype/hosts/nuke/__init__.py +++ b/openpype/hosts/nuke/__init__.py @@ -18,13 +18,7 @@ def add_implementation_envs(env, _app): new_nuke_paths.append(norm_path) env["NUKE_PATH"] = os.pathsep.join(new_nuke_paths) - # NOTE: Poping of the key is right way. But is commented because there is - # a bug in `app_launcher.py` which only change values and not remove - # existing. - # Fixed with https://github.com/pypeclub/OpenPype/pull/2655 - # but this fix requires new build - # env.pop("QT_AUTO_SCREEN_SCALE_FACTOR", None) - env["QT_AUTO_SCREEN_SCALE_FACTOR"] = "" + env.pop("QT_AUTO_SCREEN_SCALE_FACTOR", None) # Try to add QuickTime to PATH quick_time_path = "C:/Program Files (x86)/QuickTime/QTSystem" diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index a704c3ae68..4227195235 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1040,10 +1040,19 @@ class ApplicationLaunchContext: # Prepare data that will be passed to midprocess # - store arguments to a json and pass path to json as last argument # - pass environments to set + app_env = self.kwargs.pop("env", {}) json_data = { "args": self.launch_args, - "env": self.kwargs.pop("env", {}) + "env": app_env } + if app_env: + # Filter environments of subprocess + self.kwargs["env"] = { + key: value + for key, value in os.environ.items() + if key in app_env + } + # Create temp file json_temp = tempfile.NamedTemporaryFile( mode="w", prefix="op_app_args", suffix=".json", delete=False