Get LaunchInformation in tk-multi-launchapp hook

Hi!

I have a ‘rez_app_launch.py’ script for managing our Rez environment. It’s located inside ‘tk-multi-launchapp’ and configured in ‘settings.tk-multi-launchapp’ as ‘hook_app_launch: “{config}/tk-multi-launchapp/rez_app_launch.py”’.

Here, I would like to retrieve the ‘LaunchInformation’, specifically the environment variables collected and returned in the ‘startup.py’ (‘return LaunchInformation(exec_path, args, required_env)’). I need access to ‘required_env’.

I’ve attempted to use the ‘sgtk.platform’ functions, but I’m unable to access the platform or the engine from this context. Any suggestions?

Thanks in advance!

Bene

2 Likes

Very good question! I’m also curious about the answer!

1 Like

I believe by the time the before_app_launch hook is executed, the LaunchInformation’s required_env dict is merged into os.environ. So you should have full access to those variables through the standard os.environ dict.

You can read step by step through this private _launch_app method.

Loosely, this is what seems to be happening:

  1. os.environ and sys.path are stored.
  2. the prepare_launch method from an engine’s startup.py is called.
  3. the LaunchInformation’s required_env is merged into os.environ.
  4. the before_app_launch hook is called. (Users can perform any modifications to os.environ here.)
  5. the app_launch hook is called and should start the application passing os.environ as the applications environment.
  6. os.environ and sys.path for the current python process are restored.
1 Like