prepend python2 vendor for hiero and nuke

This commit is contained in:
Milan Kolar 2021-02-02 22:48:21 +01:00
parent 1d587e34df
commit 32d554b0b5

View file

@ -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)