4 from os
.path
import dirname
, exists
, join
5 from pathlib
import Path
6 from platform
import architecture
7 from shutil
import which
9 from setuptools
import Extension
, setup
11 is_win
= (architecture()[1] == "WindowsPE")
12 is_64
= (architecture()[0] == "64bit")
16 library_dirs
= [curdir
, "build"]
19 self_path
= Path(__file__
).resolve()
20 CURRENT_RELEASE
= self_path
.parent
.joinpath('VAPOURSYNTH_VERSION').read_text('utf8').split(' ')[-1].strip().split('-')[0]
24 library_dirs
.append(join("msvc_project", "x64", "Release"))
27 library_dirs
.append(join("msvc_project", "Release"))
31 # This code detects the library directory by querying the Windows Registry
32 # for the current VapourSynth directory location.
36 REGISTRY_PATH
= r
"SOFTWARE\VapourSynth"
37 REGISTRY_KEY
= "VapourSynthDLL"
38 REGISTRY_KEY_PATH
= "Path"
40 def query(hkey
, path
, key
):
43 reg_key
= winreg
.OpenKey(hkey
, path
, 0, winreg
.KEY_READ
)
44 value
, _
= winreg
.QueryValueEx(reg_key
, key
)
46 if reg_key
is not None:
47 winreg
.CloseKey(reg_key
)
51 # Locate the vapoursynth dll inside the library directories first
52 # should we find it, it is a clear indicator that VapourSynth
53 # has been compiled by the user.
54 for path
in library_dirs
:
55 dll_path
= join(path
, "vapoursynth.dll")
59 # In case the user did not compile vapoursynth by themself, we will then
62 # This is an indicator for portable installations.
65 dll_path
= which("vapoursynth.dll")
67 # If the vapoursynth.dll is not located in PATH, we then hit the registry
69 dll_path
= query(winreg
.HKEY_LOCAL_MACHINE
, REGISTRY_PATH
, REGISTRY_KEY
)
72 raise OSError("Couldn't detect vapoursynth installation path")
74 # Since the SDK is on a different directory than the DLL insert the SDK to library_dirs
75 sdkpath
= join(query(winreg
.HKEY_LOCAL_MACHINE
, REGISTRY_PATH
, REGISTRY_KEY_PATH
), "sdk", lib_suffix
)
76 if not exists(sdkpath
):
77 raise OSError("It appears you don't have the sdk installed. Please make sure you installed the sdk before running setup.py")
78 library_dirs
.append(sdkpath
)
80 # Insert the DLL Path to the library dirs
82 library_dirs
.append(dirname(dll_path
))
84 # Make sure the setup process copies the VapourSynth.dll into the site-package folder
85 print("Found VapourSynth.dll at:", dll_path
)
87 extra_data
["data_files"] = [(r
"Lib\site-packages", [dll_path
])]
92 description
="A frameserver for the 21st century",
93 url
="https://www.vapoursynth.com/",
94 download_url
="https://github.com/vapoursynth/vapoursynth",
95 author
="Fredrik Mellbin",
96 author_email
="fredrik.mellbin@gmail.com",
97 license
="LGPL 2.1 or later",
98 version
=CURRENT_RELEASE
,
99 long_description
="A portable replacement for Avisynth" if is_portable
else "A modern replacement for Avisynth",
103 "vapoursynth", [join("src", "cython", "vapoursynth.pyx")],
104 define_macros
=[("VS_USE_LATEST_API", None), ("VS_GRAPH_API", None), ("VS_CURRENT_RELEASE", CURRENT_RELEASE
)],
105 libraries
=["vapoursynth"],
106 library_dirs
=library_dirs
,
109 join("src", "cython"),
110 join("src", "vsscript")
118 exclude_package_data
={"": ("VAPOURSYNTH_VERSION",)},