forked from vapoursynth/vapoursynth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
101 lines (87 loc) · 3.54 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python
from platform import architecture
from shutil import which
from os import curdir
from os.path import join, exists, dirname
from setuptools import setup, Extension
is_win = (architecture()[1] == "WindowsPE")
is_64 = (architecture()[0] == "64bit")
extra_data = {}
library_dirs = [curdir, "build"]
if is_win:
if is_64:
library_dirs.append(join("msvc_project", "x64", "Release"))
lib_suffix = "lib64"
else:
library_dirs.append(join("msvc_project", "Release"))
lib_suffix = "lib32"
#
# This code detects the library directory by querying the Windows Registry
# for the current VapourSynth directory location.
#
import winreg
REGISTRY_PATH = r"SOFTWARE\VapourSynth"
REGISTRY_KEY = "VapourSynthDLL"
REGISTRY_KEY_PATH = "Path"
def query(hkey, path, key):
reg_key = None
try:
reg_key = winreg.OpenKey(hkey, path, 0, winreg.KEY_READ)
value, _ = winreg.QueryValueEx(reg_key, key)
finally:
if reg_key is not None:
winreg.CloseKey(reg_key)
return value
# Locate the vapoursynth dll inside the library directories first
# should we find it, it is a clear indicator that VapourSynth
# has been compiled by the user.
for path in library_dirs:
dll_path = join(path, "vapoursynth.dll")
if exists(dll_path):
break
else:
# In case the user did not compile vapoursynth by themself, we will then
# hit the path.
#
# This is an indicator for portable installations.
dll_path = which("vapoursynth.dll")
if dll_path is None:
# If the vapoursynth.dll is not located in PATH, we then hit the registry
try:
dll_path = query(winreg.HKEY_LOCAL_MACHINE, REGISTRY_PATH, REGISTRY_KEY)
except:
# Give up.
raise OSError("Couldn't detect vapoursynth installation path")
else:
# Since the SDK is on a different directory than the DLL insert the SDK to library_dirs
sdkpath = join(query(winreg.HKEY_LOCAL_MACHINE, REGISTRY_PATH, REGISTRY_KEY_PATH), "sdk", lib_suffix)
if not exists(sdkpath):
raise OSError("It appears you don't have the sdk installed. Please make sure you installed the sdk before running setup.py")
library_dirs.append(sdkpath)
# Insert the DLL Path to the library dirs
if dll_path:
library_dirs.append(dirname(dll_path))
# Make sure the setup process copies the VapourSynth.dll into the site-package folder
print("Found VapourSynth.dll at:", dll_path)
extra_data["data_files"] = [(r"Lib\site-packages", [dll_path])]
setup(
name = "VapourSynth",
description = "A frameserver for the 21st century",
url = "http://www.vapoursynth.com/",
download_url = "https://github.com/vapoursynth/vapoursynth",
author = "Fredrik Mellbin",
author_email = "[email protected]",
license = "LGPL 2.1 or later",
version = "52",
long_description = "A portable replacement for Avisynth",
platforms = "All",
ext_modules = [Extension("vapoursynth", [join("src", "cython", "vapoursynth.pyx")],
libraries = ["vapoursynth"],
library_dirs = library_dirs,
include_dirs = [curdir, join("src", "cython")])],
setup_requires=[
'setuptools>=18.0',
"Cython",
],
**extra_data
)