diff --git a/openpype/hosts/flame/api/scripts/wiretap_com.py b/openpype/hosts/flame/api/scripts/wiretap_com.py index 0cda25804b..4e54dfd913 100644 --- a/openpype/hosts/flame/api/scripts/wiretap_com.py +++ b/openpype/hosts/flame/api/scripts/wiretap_com.py @@ -9,31 +9,14 @@ import json import xml.dom.minidom as minidom from copy import deepcopy import datetime - -FLAME_V = os.getenv("OPENPYPE_FLAME_VERSION") - -if not FLAME_V: - raise KeyError("Missing key in environment `OPENPYPE_FLAME_VERSION`") - -try: - from libwiretapPythonClientAPI import ( # noqa - WireTapClientInit) -except ImportError: - flame_python_path = "/opt/Autodesk/flame_{}/python".format(FLAME_V) - flame_exe_path = ( - "/opt/Autodesk/flame_{}/bin/flame.app" - "/Contents/MacOS/startApp").format(FLAME_V) - - sys.path.append(flame_python_path) - - from libwiretapPythonClientAPI import ( # noqa - WireTapClientInit, - WireTapClientUninit, - WireTapNodeHandle, - WireTapServerHandle, - WireTapInt, - WireTapStr - ) +from libwiretapPythonClientAPI import ( # noqa + WireTapClientInit, + WireTapClientUninit, + WireTapNodeHandle, + WireTapServerHandle, + WireTapInt, + WireTapStr +) class WireTapCom(object): diff --git a/openpype/hosts/flame/hooks/pre_flame_setup.py b/openpype/hosts/flame/hooks/pre_flame_setup.py index 512433b718..fc6b65c958 100644 --- a/openpype/hosts/flame/hooks/pre_flame_setup.py +++ b/openpype/hosts/flame/hooks/pre_flame_setup.py @@ -20,10 +20,8 @@ class FlamePrelaunch(PreLaunchHook): app_groups = ["flame"] # todo: replace version number with avalon launch app version - flame_python_exe = ( - "/opt/Autodesk/python/{OPENPYPE_FLAME_VERSION}" - "/bin/python2.7" - ) + flame_python_exe = os.getenv("OPENPYPE_FLAME_PYTHON_EXEC") + flame_pythonpath = os.getenv("OPENPYPE_FLAME_PYTHONPATH") wtc_script_path = os.path.join( opflame.HOST_DIR, "api", "scripts", "wiretap_com.py") @@ -60,7 +58,6 @@ class FlamePrelaunch(PreLaunchHook): "FieldDominance": "PROGRESSIVE" } - data_to_script = { # from settings "host_name": _env.get("FLAME_WIRETAP_HOSTNAME") or hostname, @@ -77,12 +74,25 @@ class FlamePrelaunch(PreLaunchHook): self.log.info(pformat(dict(_env))) self.log.info(pformat(data_to_script)) + # add to python path from settings + self._add_pythonpath() + app_arguments = self._get_launch_arguments(data_to_script) opfapi.setup(self.launch_context.env) self.launch_context.launch_args.extend(app_arguments) + def _add_pythonpath(self): + pythonpath = self.launch_context.env.get("PYTHONPATH") + + # separate it explicity by `;` that is what we use in settings + new_pythonpath = self.flame_pythonpath.split(";") + new_pythonpath += pythonpath.split(os.pathsep) + + self.launch_context.env["PYTHONPATH"] = os.pathsep.join(new_pythonpath) + + def _get_launch_arguments(self, script_data): # Dump data to string dumped_script_data = json.dumps(script_data) diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 3a097d2b37..7fe0432fdf 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -130,7 +130,8 @@ "linux": [] }, "environment": { - "OPENPYPE_FLAME_VERSION": "2021" + "OPENPYPE_FLAME_PYTHON_EXEC": "/opt/Autodesk/python/2021/bin/python2.7", + "OPENPYPE_FLAME_PYTHONPATH": "/opt/Autodesk/flame_2021/python" } }, "__dynamic_keys_labels__": {