From 32d554b0b500d78256ececfda5972b16337b5934 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 2 Feb 2021 22:48:21 +0100 Subject: [PATCH] prepend python2 vendor for hiero and nuke --- pype/hooks/global/pre_python2_vendor.py | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pype/hooks/global/pre_python2_vendor.py diff --git a/pype/hooks/global/pre_python2_vendor.py b/pype/hooks/global/pre_python2_vendor.py new file mode 100644 index 0000000000..19d7f59991 --- /dev/null +++ b/pype/hooks/global/pre_python2_vendor.py @@ -0,0 +1,36 @@ +import os +from pype.lib import PreLaunchHook + + +class PrePython2Vendor(PreLaunchHook): + """Prepend python 2 dependencies for py2 hosts.""" + # WARNING This hook will probably be deprecated in Pype 3 - kept for test + order = 10 + app_groups = ["hiero", "nuke"] + + def execute(self): + # Prepare vendor dir path + self.log.info( + f"adding global python 2 vendor" + ) + PYPE_ROOT = os.getenv("PYPE_ROOT") + python_2_vendor = os.path.join( + PYPE_ROOT, + "pype", + "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) \ No newline at end of file