From bf07cbf494e52be3f53dc542c84039256b36771d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 18 May 2021 13:24:21 +0200 Subject: [PATCH] initial implementation of blender's add_implementation_envs --- openpype/hosts/blender/__init__.py | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/openpype/hosts/blender/__init__.py b/openpype/hosts/blender/__init__.py index e69de29bb2..1a81c3add1 100644 --- a/openpype/hosts/blender/__init__.py +++ b/openpype/hosts/blender/__init__.py @@ -0,0 +1,41 @@ +import os + + +def add_implementation_envs(env): + """Modify environments to contain all required for implementation.""" + # Prepare path to implementation script + implementation_user_script_path = os.path.join( + os.environ["OPENPYPE_REPOS_ROOT"], + "repos", + "avalon-core", + "setup", + "blender" + ) + + # Add blender implementation script path to PYTHONPATH + python_path = env.get("PYTHONPATH") or "" + python_path_parts = [ + path + for path in python_path.split(os.pathsep) + if path + ] + python_path_parts.insert(0, implementation_user_script_path) + env["PYTHONPATH"] = os.pathsep.join(python_path_parts) + + # Modify Blender user scripts path + blender_user_scripts = env.get("BLENDER_USER_SCRIPTS") or "" + previous_user_scripts = [] + for path in blender_user_scripts.split(os.pathsep): + if path and os.path.exists(path): + path = os.path.normpath(path) + if path != implementation_user_script_path: + previous_user_scripts.append(path) + + env["OPENPYPE_BLENDER_USER_SCRIPTS"] = os.pathsep.join( + previous_user_scripts + ) + env["BLENDER_USER_SCRIPTS"] = implementation_user_script_path + + # Define Qt binding if not defined + if not env.get("QT_PREFERRED_BINDING"): + env["QT_PREFERRED_BINDING"] = "PySide2"