mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
* OP-6780 - vendorized necessary libraries for Python 3.6 * OP-6780 - better resolution of app_version * Update openpype/hosts/fusion/addon.py Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com> * OP-6780 - add vendorized libraries even before menu creation This should help when version of Fusion > 17, but it is still using 3.6 * OP-6780 - added todo message to remember to remove this * OP-6780 - move injection of PYTHONPATH much sooner At previous position it was too late. * OP-6780 - better capture of broken imports * OP-6780 - SyntaxError is thrown only if directly importing * OP-6780 - remove unnecessary imports Only urllib3 and attrs are actually needed * OP-6780 - vendorize even directly in Fusion if Python < 3.7 * OP-6780 - remove update of PYTHONPATH in addon More important and required is check directly in interpreter in Fusion, it doesn't make sense to pollute addon and have it on two places. It might get removed altogether in next-minor. * OP-6780 - added comment --------- Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
import os
|
|
import re
|
|
from openpype.modules import OpenPypeModule, IHostAddon
|
|
from openpype.lib import Logger
|
|
|
|
FUSION_HOST_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
# FUSION_VERSIONS_DICT is used by the pre-launch hooks
|
|
# The keys correspond to all currently supported Fusion versions
|
|
# Each value is a list of corresponding Python home variables and a profile
|
|
# number, which is used by the profile hook to set Fusion profile variables.
|
|
FUSION_VERSIONS_DICT = {
|
|
9: ("FUSION_PYTHON36_HOME", 9),
|
|
16: ("FUSION16_PYTHON36_HOME", 16),
|
|
17: ("FUSION16_PYTHON36_HOME", 16),
|
|
18: ("FUSION_PYTHON3_HOME", 16),
|
|
}
|
|
|
|
|
|
def get_fusion_version(app_name):
|
|
"""
|
|
The function is triggered by the prelaunch hooks to get the fusion version.
|
|
|
|
`app_name` is obtained by prelaunch hooks from the
|
|
`launch_context.env.get("AVALON_APP_NAME")`.
|
|
|
|
To get a correct Fusion version, a version number should be present
|
|
in the `applications/fusion/variants` key
|
|
of the Blackmagic Fusion Application Settings.
|
|
"""
|
|
|
|
log = Logger.get_logger(__name__)
|
|
|
|
if not app_name:
|
|
return
|
|
|
|
app_version_candidates = re.findall(r"\d+", app_name)
|
|
if not app_version_candidates:
|
|
return
|
|
for app_version in app_version_candidates:
|
|
if int(app_version) in FUSION_VERSIONS_DICT:
|
|
return int(app_version)
|
|
else:
|
|
log.info(
|
|
"Unsupported Fusion version: {app_version}".format(
|
|
app_version=app_version
|
|
)
|
|
)
|
|
|
|
|
|
class FusionAddon(OpenPypeModule, IHostAddon):
|
|
name = "fusion"
|
|
host_name = "fusion"
|
|
|
|
def initialize(self, module_settings):
|
|
self.enabled = True
|
|
|
|
def get_launch_hook_paths(self, app):
|
|
if app.host_name != self.host_name:
|
|
return []
|
|
return [os.path.join(FUSION_HOST_DIR, "hooks")]
|
|
|
|
def add_implementation_envs(self, env, app):
|
|
# Set default values if are not already set via settings
|
|
|
|
defaults = {"OPENPYPE_LOG_NO_COLORS": "Yes"}
|
|
for key, value in defaults.items():
|
|
if not env.get(key):
|
|
env[key] = value
|
|
|
|
def get_workfile_extensions(self):
|
|
return [".comp"]
|