mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #5223 from ynput/bugfix/colorspace_compatibility_check
This commit is contained in:
commit
4771e0f66c
1 changed files with 21 additions and 15 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from copy import deepcopy
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import platform
|
||||
import contextlib
|
||||
|
|
@ -237,12 +236,13 @@ def get_data_subprocess(config_path, data_type):
|
|||
return json.loads(return_json_data)
|
||||
|
||||
|
||||
def compatible_python():
|
||||
"""Only 3.9 or higher can directly use PyOpenColorIO in ocio_wrapper"""
|
||||
compatible = False
|
||||
if sys.version_info.major == 3 and sys.version_info.minor >= 9:
|
||||
compatible = True
|
||||
return compatible
|
||||
def compatibility_check():
|
||||
"""Making sure PyOpenColorIO is importable"""
|
||||
try:
|
||||
import PyOpenColorIO # noqa: F401
|
||||
except ImportError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_ocio_config_colorspaces(config_path):
|
||||
|
|
@ -257,12 +257,15 @@ def get_ocio_config_colorspaces(config_path):
|
|||
Returns:
|
||||
dict: colorspace and family in couple
|
||||
"""
|
||||
if compatible_python():
|
||||
from ..scripts.ocio_wrapper import _get_colorspace_data
|
||||
return _get_colorspace_data(config_path)
|
||||
else:
|
||||
if not compatibility_check():
|
||||
# python environment is not compatible with PyOpenColorIO
|
||||
# needs to be run in subprocess
|
||||
return get_colorspace_data_subprocess(config_path)
|
||||
|
||||
from openpype.scripts.ocio_wrapper import _get_colorspace_data
|
||||
|
||||
return _get_colorspace_data(config_path)
|
||||
|
||||
|
||||
def get_colorspace_data_subprocess(config_path):
|
||||
"""Get colorspace data via subprocess
|
||||
|
|
@ -290,12 +293,15 @@ def get_ocio_config_views(config_path):
|
|||
Returns:
|
||||
dict: `display/viewer` and viewer data
|
||||
"""
|
||||
if compatible_python():
|
||||
from ..scripts.ocio_wrapper import _get_views_data
|
||||
return _get_views_data(config_path)
|
||||
else:
|
||||
if not compatibility_check():
|
||||
# python environment is not compatible with PyOpenColorIO
|
||||
# needs to be run in subprocess
|
||||
return get_views_data_subprocess(config_path)
|
||||
|
||||
from openpype.scripts.ocio_wrapper import _get_views_data
|
||||
|
||||
return _get_views_data(config_path)
|
||||
|
||||
|
||||
def get_views_data_subprocess(config_path):
|
||||
"""Get viewers data via subprocess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue