Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix PXR_PLUGINPATH_NAME and path appending #5

Merged
merged 8 commits into from
Jun 11, 2024
57 changes: 31 additions & 26 deletions client/ayon_usd/hooks/pre_resolver_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,24 @@ def execute(self):
f"No USD asset resolver settings for {self.app_name}.")
return

pxr_plugin_paths = []
ld_path = []
python_path =[]
try:
pxr_plugin_paths = self.launch_context.env[
"PXR_PLUGINPATH_NAME"].split(os.pathsep)
except KeyError:
pxr_plugin_paths = []

try:
ld_path = self.launch_context.env[
"LD_LIBRARY_PATH"].split(os.pathsep)
except KeyError:
ld_path = []

try:
python_path = self.launch_context.env[
"PYTHONPATH"].split(os.pathsep)
except KeyError:
python_path = []

for resolver in resolver_settings:
if resolver["app_name"] != self.app_name:
continue
Expand Down Expand Up @@ -110,7 +125,7 @@ def execute(self):
pxr_plugin_paths.append(
(
resolver_dir / "ayonUsdResolver" /
"resources" / "plugInfo.json"
"resources"
).as_posix()
)
ld_path.append(
Expand All @@ -120,28 +135,18 @@ def execute(self):
"lib" / "python").as_posix())
self.log.info(f"Asset resolver {self.app_name} initiated.")

if self.launch_context.env.get("PXR_PLUGINPATH_NAME"):
pxr_plugin_paths.append(
self.launch_context.env["PXR_PLUGINPATH_NAME"].split(
os.pathsep)
if pxr_plugin_paths:
self.launch_context.env["PXR_PLUGINPATH_NAME"] = os.pathsep.join(
pxr_plugin_paths
)

self.launch_context.env["PXR_PLUGINPATH_NAME"] = os.pathsep.join(
pxr_plugin_paths
)

self.launch_context.env["PYTHONPATH"] += os.pathsep.join(python_path)

if system().lower() == "windows":
self.launch_context.env["PATH"] += os.pathsep.join(ld_path)
else:
self.launch_context.env["LD_LIBRARY_PATH"] += \
os.pathsep.join(ld_path)

# is there used in the application? Can it hold multiple values?
# self.launch_context.env["USD_ASSET_RESOLVER"] = \
# resolver_dir.as_posix()
if python_path:
self.launch_context.env["PYTHONPATH"] = os.pathsep.join(
python_path
)

# TODO: move debug options to AYON settings
self.launch_context.env["TF_DEBUG"] = "1"
self.launch_context.env["AYONLOGGERLOGLVL"] = "INFO"
if ld_path:
env_key = "PATH" if system().lower() == "windows" else "LD_LIBRARY_PATH" # noqa: E501
if existing_path := self.launch_context.env.get(env_key):
ld_path.insert(0, existing_path)
self.launch_context.env[env_key] = os.pathsep.join(ld_path)