Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created November 13, 2023 13:33
Show Gist options
  • Save BigRoy/f9796f8cb5020944dbdf7fafd6935652 to your computer and use it in GitHub Desktop.
Save BigRoy/f9796f8cb5020944dbdf7fafd6935652 to your computer and use it in GitHub Desktop.
Example AYON / OpenPype PreLaunchHook to insert Ayon's FFMPEG to PATH environment variable on launch of applications
import os
from openpype.lib.applications import PreLaunchHook, LaunchTypes
from openpype.lib.vendor_bin_utils import get_ffmpeg_tool_path
class AddFFMPEGToPath(PreLaunchHook):
"""Insert Ayon FFMPEG in `PATH`"""
# Should be as last hook because must change launch arguments to string
app_groups = {"*"}
platforms = {"*"}
launch_types = {LaunchTypes.local}
def execute(self):
path = self.launch_context.env.get("PATH")
ffmpeg = get_ffmpeg_tool_path()
ffmpeg_bin = os.path.dirname(ffmpeg)
if path:
path = os.pathsep.join([ffmpeg_bin, path])
else:
path = ffmpeg_bin
self.launch_context.env["PATH"] = path
@BigRoy
Copy link
Author

BigRoy commented Nov 13, 2023

Based on AYON discord discussion here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment