mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1261 from ynput/bugfix/strip-launcher-paths-from-env-hook
Filter launcher paths from `PATH` passed to host
This commit is contained in:
commit
6be8b7fd02
1 changed files with 30 additions and 0 deletions
30
client/ayon_core/hooks/pre_remove_launcher_paths.py
Normal file
30
client/ayon_core/hooks/pre_remove_launcher_paths.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
""""Pre launch hook to remove launcher paths from the system."""
|
||||
import os
|
||||
|
||||
from ayon_applications import PreLaunchHook
|
||||
|
||||
|
||||
class PreRemoveLauncherPaths(PreLaunchHook):
|
||||
"""Remove launcher paths from the system.
|
||||
|
||||
This hook is used to remove launcher paths from the system before launching
|
||||
an application. It is used to ensure that the application is launched with
|
||||
the correct environment variables. Especially for Windows, where
|
||||
paths in `PATH` are used to load DLLs. This is important to avoid
|
||||
conflicts with other applications that may have the same DLLs in their
|
||||
paths.
|
||||
"""
|
||||
order = 1
|
||||
|
||||
def execute(self) -> None:
|
||||
"""Execute the hook."""
|
||||
# Remove launcher paths from the system
|
||||
ayon_root = os.path.normpath(os.environ["AYON_ROOT"])
|
||||
|
||||
paths = [
|
||||
path
|
||||
for path in self.launch_context.env.get(
|
||||
"PATH", "").split(os.pathsep)
|
||||
if not os.path.normpath(path).startswith(ayon_root)
|
||||
]
|
||||
self.launch_context.env["PATH"] = os.pathsep.join(paths)
|
||||
Loading…
Add table
Add a link
Reference in a new issue