forked from pupil-labs/pyndsi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
107 lines (95 loc) · 3.32 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
102
103
104
105
106
107
"""
(*)~----------------------------------------------------------------------------------
Pupil - eye tracking platform
Copyright (C) 2012-2015 Pupil Labs
Distributed under the terms of the CC BY-NC-SA License.
License details are in the file license.txt, distributed as part of this software.
----------------------------------------------------------------------------------~(*)
"""
import glob
import io
import os
import platform
import re
import numpy
from Cython.Build import cythonize
from setuptools import Extension, setup
requirements = ["numpy", "pyzmq", "pyre"]
def read(*names, **kwargs):
with io.open(
os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8"),
) as fp:
return fp.read()
# pip's single-source version method as described here:
# https://python-packaging-user-guide.readthedocs.io/single_source_version/
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
libs = []
library_dirs = []
include_dirs = []
extra_link_args = []
extra_objects = []
include_dirs = [numpy.get_include()]
if platform.system() == "Darwin":
include_dirs += ["/usr/local/opt/jpeg-turbo/include/"]
libs += ["turbojpeg"]
library_dirs += ["/usr/local/opt/jpeg-turbo/lib/"]
libs += ["avutil", "avformat", "avcodec", "swscale"]
elif platform.system() == "Linux":
libs = ["rt", "turbojpeg"]
libs += ["avutil", "avformat", "avcodec", "swscale"]
elif platform.system() == "Windows":
libs = ["winmm"]
tj_dir = "C:\\work\\libjpeg-turbo-VC64"
tj_lib = tj_dir + "\\lib\\turbojpeg.lib"
include_dirs += [tj_dir + "\\include"]
extra_objects += [tj_lib]
include_dirs += ["ndsi\\h264\\windows"]
ffmpeg_libs = "C:\\work\\ffmpeg-4.0-win64-dev\\lib"
include_dirs += ["C:\\work\\ffmpeg-4.0-win64-dev\\include"]
libs += [
ffmpeg_libs + "\\avutil",
ffmpeg_libs + "\\avformat",
ffmpeg_libs + "\\avcodec",
ffmpeg_libs + "\\swscale",
]
h264_sources = glob.glob("ndsi/h264/*.cpp")
if platform.system() == "Windows":
h264_sources += glob.glob("ndsi/h264/windows/*.cpp")
extensions = [
Extension(
name="ndsi.frame",
sources=h264_sources + ["ndsi/frame.pyx"],
include_dirs=[numpy.get_include()] + include_dirs,
library_dirs=library_dirs,
libraries=libs,
extra_link_args=extra_link_args + ["-std=c++11"],
extra_compile_args=["-std=c++11", "-D__STDC_FORMAT_MACROS=1"],
extra_objects=extra_objects,
language="c++",
),
Extension(
name="ndsi.writer",
sources=h264_sources + ["ndsi/writer.pyx"],
include_dirs=[numpy.get_include()] + include_dirs,
library_dirs=library_dirs,
libraries=libs,
extra_link_args=extra_link_args + ["-std=c++11"],
extra_compile_args=["-std=c++11", "-D__STDC_FORMAT_MACROS=1"],
extra_objects=extra_objects,
language="c++",
),
]
setup(
name="ndsi",
version=find_version("ndsi", "__init__.py"),
install_requires=requirements,
description="Remote Device Sensor Interface",
packages=["ndsi"],
ext_modules=cythonize(extensions),
)