Skip to content

Commit

Permalink
Merge pull request #5 from ynput/bugfix/fix-pxr_pluginpath_name
Browse files Browse the repository at this point in the history
fix `PXR_PLUGINPATH_NAME` and path appending
  • Loading branch information
antirotor authored Jun 11, 2024
2 parents fcb21d8 + ab60c7f commit 291b456
Showing 1 changed file with 31 additions and 26 deletions.
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)

0 comments on commit 291b456

Please sign in to comment.