ayon-core/openpype/hosts/max/hooks/inject_python.py
Jakub Trllo 3ae020f064
Applications: Launch hooks cleanup (#5395)
* ApplicationManager can have more granular way how applications are launched

* executable is optional to be able create ApplicationLaunchContext

* launch context can run prelaunch hooks without launching application

* 'get_app_environments_for_context' is using launch context to prepare environments

* added 'launch_type' as one of filtering options for LaunchHook

* added 'local' launch type filter to existing launch hooks

* define 'automated' launch type in remote publish function

* modified publish and extract environments cli commands

* launch types are only for local by default

* fix import

* fix launch types of global host data

* change order or kwargs

* change unreal filter attribute

* use set instead of list

* removed '__init__' from celaction hooks

* use 'CELACTION_ROOT_DIR' in pre setup

* use full import from applications
2023-08-03 12:24:23 +02:00

20 lines
650 B
Python

# -*- coding: utf-8 -*-
"""Pre-launch hook to inject python environment."""
import os
from openpype.lib.applications import PreLaunchHook, LaunchTypes
class InjectPythonPath(PreLaunchHook):
"""Inject OpenPype environment to 3dsmax.
Note that this works in combination whit 3dsmax startup script that
is translating it back to PYTHONPATH for cases when 3dsmax drops PYTHONPATH
environment.
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = {"3dsmax"}
launch_types = {LaunchTypes.local}
def execute(self):
self.launch_context.env["MAX_PYTHONPATH"] = os.environ["PYTHONPATH"]