From 7b8826bb9a871f87790e946b78ac2498f3e68c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 21 May 2024 16:53:17 +0200 Subject: [PATCH 1/6] :bug: fix PRX_PLUGINPATH_NAME it needs to point to the directory, not to the json file itself --- client/ayon_usd/hooks/pre_resolver_init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index d74aad8..028990a 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -110,7 +110,7 @@ def execute(self): pxr_plugin_paths.append( ( resolver_dir / "ayonUsdResolver" / - "resources" / "plugInfo.json" + "resources" ).as_posix() ) ld_path.append( @@ -143,5 +143,5 @@ def execute(self): # resolver_dir.as_posix() # TODO: move debug options to AYON settings - self.launch_context.env["TF_DEBUG"] = "1" + self.launch_context.env["TF_DEBUG"] = "AYONUSDRESOLVER_RESOLVER" self.launch_context.env["AYONLOGGERLOGLVL"] = "INFO" From eb1ecb218bb8f1283c74cb9d35415d3efc763d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 21 May 2024 17:22:07 +0200 Subject: [PATCH 2/6] :bug: fix path appending --- client/ayon_usd/hooks/pre_resolver_init.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index 028990a..bfe6168 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -130,13 +130,15 @@ def execute(self): pxr_plugin_paths ) - self.launch_context.env["PYTHONPATH"] += os.pathsep.join(python_path) + self.launch_context.env["PYTHONPATH"] += (os.pathsep + + os.pathsep.join(python_path)) if system().lower() == "windows": - self.launch_context.env["PATH"] += os.pathsep.join(ld_path) + self.launch_context.env["PATH"] += (os.pathsep + + os.pathsep.join(ld_path)) else: self.launch_context.env["LD_LIBRARY_PATH"] += \ - os.pathsep.join(ld_path) + os.pathsep + os.pathsep.join(ld_path) # is there used in the application? Can it hold multiple values? # self.launch_context.env["USD_ASSET_RESOLVER"] = \ From 46689fcf41d77b79375c847cb3ec390638e64753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 27 May 2024 15:21:50 +0200 Subject: [PATCH 3/6] :bug: better handling of paths --- client/ayon_usd/hooks/pre_resolver_init.py | 51 +++++++++++++--------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index bfe6168..dcbc53e 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -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.get( + "PXR_PLUGINPATH_NAME").split(os.pathsep) + except AttributeError: + pxr_plugin_paths = [] + + try: + ld_path = self.launch_context.env.get( + "LD_LIBRARY_PATH").split(os.pathsep) + except AttributeError: + ld_path = [] + + try: + python_path = self.launch_context.env.get( + "PYTHONPATH").split(os.pathsep) + except AttributeError: + python_path = [] + for resolver in resolver_settings: if resolver["app_name"] != self.app_name: continue @@ -120,29 +135,23 @@ 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 + - os.pathsep.join(python_path)) + if python_path: + self.launch_context.env["PYTHONPATH"] = os.pathsep.join( + python_path + ) if system().lower() == "windows": - self.launch_context.env["PATH"] += (os.pathsep + - os.pathsep.join(ld_path)) - else: + if ld_path: + self.launch_context.env["PATH"] = \ + os.pathsep + os.pathsep.join(ld_path) + elif ld_path: self.launch_context.env["LD_LIBRARY_PATH"] += \ - os.pathsep + 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() + os.pathsep + os.pathsep.join(ld_path) # TODO: move debug options to AYON settings self.launch_context.env["TF_DEBUG"] = "AYONUSDRESOLVER_RESOLVER" From 7082b23d79920f7ef1fea39ae839e8a6a00eaa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 27 May 2024 15:23:07 +0200 Subject: [PATCH 4/6] :recycle: remove logging options --- client/ayon_usd/hooks/pre_resolver_init.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index dcbc53e..b77aaa5 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -152,7 +152,3 @@ def execute(self): elif ld_path: self.launch_context.env["LD_LIBRARY_PATH"] += \ os.pathsep + os.pathsep.join(ld_path) - - # TODO: move debug options to AYON settings - self.launch_context.env["TF_DEBUG"] = "AYONUSDRESOLVER_RESOLVER" - self.launch_context.env["AYONLOGGERLOGLVL"] = "INFO" From ccf65e1fd75abe1c4b2bc4f4c2d3ddd4739872da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 4 Jun 2024 11:55:36 +0200 Subject: [PATCH 5/6] :bug: fix existing env vars resolution --- client/ayon_usd/hooks/pre_resolver_init.py | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index b77aaa5..5f9c550 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -74,20 +74,20 @@ def execute(self): return try: - pxr_plugin_paths = self.launch_context.env.get( - "PXR_PLUGINPATH_NAME").split(os.pathsep) + pxr_plugin_paths = self.launch_context.env[ + "PXR_PLUGINPATH_NAME"].split(os.pathsep) except AttributeError: pxr_plugin_paths = [] try: - ld_path = self.launch_context.env.get( - "LD_LIBRARY_PATH").split(os.pathsep) + ld_path = self.launch_context.env[ + "LD_LIBRARY_PATH"].split(os.pathsep) except AttributeError: ld_path = [] try: - python_path = self.launch_context.env.get( - "PYTHONPATH").split(os.pathsep) + python_path = self.launch_context.env[ + "PYTHONPATH"].split(os.pathsep) except AttributeError: python_path = [] @@ -145,10 +145,8 @@ def execute(self): python_path ) - if system().lower() == "windows": - if ld_path: - self.launch_context.env["PATH"] = \ - os.pathsep + os.pathsep.join(ld_path) - elif ld_path: - self.launch_context.env["LD_LIBRARY_PATH"] += \ - os.pathsep + os.pathsep.join(ld_path) + 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) From e100c93009f16850db1d6d77a9d48c0656d921d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 4 Jun 2024 12:21:39 +0200 Subject: [PATCH 6/6] :bug: change exception --- client/ayon_usd/hooks/pre_resolver_init.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index 5f9c550..7af4b13 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -76,19 +76,19 @@ def execute(self): try: pxr_plugin_paths = self.launch_context.env[ "PXR_PLUGINPATH_NAME"].split(os.pathsep) - except AttributeError: + except KeyError: pxr_plugin_paths = [] try: ld_path = self.launch_context.env[ "LD_LIBRARY_PATH"].split(os.pathsep) - except AttributeError: + except KeyError: ld_path = [] try: python_path = self.launch_context.env[ "PYTHONPATH"].split(os.pathsep) - except AttributeError: + except KeyError: python_path = [] for resolver in resolver_settings: