Hello,
linking AYON + Rez thread on discord.
In the thread there are some test runs by @luke.whitehorn
He also shared a prelaunch hook that’s used with rez.
from ayon_applications import PreLaunchHook
import os
class IngestRezEnv(PreLaunchHook):
"""
Allows Rez to pick up environment variables that have been modified by AYON
This prelaunch hook should run last so that all required environment variables
are already modified by the time thie executes.
"""
order = 1010
def execute(self):
self.log.debug("Rez prelaunch hook begin")
# See which env vars differ from os.environ
rez_inherit_keys = [
k
for k in self.data.get("env")
if k not in os.environ or self.data["env"][k] != os.environ.get(k)
]
self.log.info(
f"Setting Rez to inherit the following environment variables: {rez_inherit_keys}"
)
self.launch_context.env.update(
{
"REZ_PARENT_VARIABLES": " ".join(
self.launch_context.env.get("REZ_PARENT_VARIABLES", "").split()
+ rez_inherit_keys
)
}
)
self.log.info(
f'Setting REZ_PARENT_VARIABLES to {self.data["env"]["REZ_PARENT_VARIABLES"]}'
)
self.log.debug("Rez prelaunch hook complete")