2Platform detection and environment setup utilities.
9from pathlib
import Path
13 """Get the current platform name."""
14 system = platform.system().lower()
15 if system ==
"darwin":
17 elif system ==
"windows":
19 elif system ==
"linux":
26 """Get platform-specific paths for DaVinci Resolve scripting API."""
29 if current_platform ==
"macos":
31 "/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting"
34 "/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so"
37 elif current_platform ==
"windows":
38 program_data = Path(os.environ.get(
"PROGRAMDATA",
"C:\\ProgramData"))
39 program_files = Path(os.environ.get(
"PROGRAMFILES",
"C:\\Program Files"))
50 program_files /
"Blackmagic Design" /
"DaVinci Resolve" /
"fusionscript.dll"
53 elif current_platform ==
"linux":
55 api_path = Path(
"/opt/resolve/Developer/Scripting")
56 lib_path = Path(
"/opt/resolve/libs/fusionscript.so")
59 raise RuntimeError(f
"Unsupported platform: {current_platform}")
64 "modules_path": api_path /
"Modules",
69 """Set up environment variables for DaVinci Resolve scripting."""
74 os.environ[
"RESOLVE_SCRIPT_API"] = str(paths[
"api_path"])
75 os.environ[
"RESOLVE_SCRIPT_LIB"] = str(paths[
"lib_path"])
78 modules_path_str = str(paths[
"modules_path"])
79 if modules_path_str
not in sys.path:
80 sys.path.insert(0, modules_path_str)
88 """Check if DaVinci Resolve is properly installed."""
92 "api_path_exists": paths[
"api_path"].exists(),
93 "lib_path_exists": paths[
"lib_path"].exists(),
94 "modules_path_exists": paths[
"modules_path"].exists(),
99 """Check if DaVinci Resolve is currently running."""
103 if current_platform ==
"windows":
106 result = subprocess.run(
107 [
"tasklist",
"/FI",
"IMAGENAME eq Resolve.exe"],
112 return "Resolve.exe" in result.stdout
114 elif current_platform
in [
"macos",
"linux"]:
117 result = subprocess.run(
118 [
"pgrep",
"-f",
"DaVinci Resolve"], capture_output=
True, check=
False
120 return result.returncode == 0