From ff640f0ac35210c5393121ce746d8c3a244d52c1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 15 Apr 2021 19:08:10 +0200 Subject: [PATCH] moved back python 2 prelaunch hook --- openpype/hooks/pre_python_2_prelaunch.py | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 openpype/hooks/pre_python_2_prelaunch.py diff --git a/openpype/hooks/pre_python_2_prelaunch.py b/openpype/hooks/pre_python_2_prelaunch.py new file mode 100644 index 0000000000..8232f35623 --- /dev/null +++ b/openpype/hooks/pre_python_2_prelaunch.py @@ -0,0 +1,35 @@ +import os +from openpype.lib import PreLaunchHook + + +class PrePython2Vendor(PreLaunchHook): + """Prepend python 2 dependencies for py2 hosts.""" + # WARNING This hook will probably be deprecated in OpenPype 3 - kept for + # test + order = 10 + app_groups = ["hiero", "nuke", "nukex", "unreal", "maya", "houdini"] + + def execute(self): + # Prepare vendor dir path + self.log.info("adding global python 2 vendor") + pype_root = os.getenv("OPENPYPE_REPOS_ROOT") + python_2_vendor = os.path.join( + pype_root, + "openpype", + "vendor", + "python", + "python_2" + ) + + # Add Python 2 modules + python_paths = [ + python_2_vendor + ] + + # Load PYTHONPATH from current launch context + python_path = self.launch_context.env.get("PYTHONPATH") + if python_path: + python_paths.append(python_path) + + # Set new PYTHONPATH to launch context environments + self.launch_context.env["PYTHONPATH"] = os.pathsep.join(python_paths)