-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
126 lines (113 loc) · 3.6 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from setuptools import setup, find_packages
from setuptools.extension import Extension
import subprocess
import os
import numpy as np
here = os.path.abspath(os.path.dirname(__file__))
about = {}
with open(os.path.join(here, "src", "flowty", "__version__.py"), "r") as f:
exec(f.read(), about)
def get_cli_output(cmd):
if isinstance(cmd, str):
cmd = cmd.split()
return subprocess.check_output(cmd).decode("utf-8")
# libs are of the form -llibname so we drop the first 2 chars to get
# libname only.
opencv_libs = get_cli_output("pkg-config --libs opencv4").split()
opencv_cflags = get_cli_output("pkg-config --cflags opencv4").split()
def cython_extension(
pyx_file,
language="c++",
name=None,
include_dirs=None,
extra_compile_args=None,
extra_link_args=None,
):
if include_dirs is None:
include_dirs = []
if extra_compile_args is None:
extra_compile_args = []
if extra_link_args is None:
extra_link_args = []
if name is None:
name = pyx_file[len("src/"):-len(".pyx")].replace("/", ".")
return Extension(
name,
sources=[pyx_file],
language="c++",
libraries=["stdc++"],
include_dirs=[np.get_include(), *include_dirs],
extra_compile_args=opencv_cflags + extra_compile_args,
extra_link_args=opencv_libs + extra_link_args,
)
extensions = [
cython_extension(path, extra_compile_args=['-std=c++11'])
for path in [
"src/flowty/cv/core.pyx",
"src/flowty/cv/videoio.pyx",
"src/flowty/cv/imgcodecs.pyx",
"src/flowty/cv/cuda.pyx",
"src/flowty/cv/optflow.pyx",
"src/flowty/cv/cuda_optflow.pyx",
]
]
docs_require = ["sphinx"]
tests_require = ["pytest", "imageio", "cython"]
if __name__ == '__main__':
setup(
name=about["__title__"],
description=about["__description__"],
version=about["__version__"],
ext_modules=extensions,
packages=find_packages('src') + ['flowty.algorithms'],
package_dir={'': 'src'},
install_requires=["numpy", "tqdm"],
extras_require={
"docs": docs_require,
"test": tests_require,
"dev": tests_require + docs_require,
},
# Include package data specified in MANIFEST.in
include_package_data=True,
classifiers=[
# How mature is this project? Common values
# are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
entry_points={
'console_scripts': ['flowty=flowty.flowty:main']
},
keywords=[
"computer-vision",
"optical-flow",
"optical",
"flow",
"computer",
"vision",
"opencv",
"cython",
"cuda",
"gpu",
"tvl1",
"farneback",
"brox",
"flowty",
],
author=about["__author__"],
author_email=about["__author_email__"],
license=about["__license__"],
url="http://github.com/willprice/flowty",
project_urls={
"Bug Tracker": "https://github.com/willprice/flowty/issues",
"Documentation": "https://flowty.readthedocs.io",
"Source Code": "http://github.com/willprice/flowty",
},
zip_safe=False
)