-
Notifications
You must be signed in to change notification settings - Fork 890
/
Copy pathsetup.py
54 lines (42 loc) · 1.34 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
from setuptools import setup
from setuptools.dist import Distribution
import pip
import os
import sys
numpy_version = ""
# Get required numpy version
for package in pip.get_installed_distributions():
if package.key == "numpy":
numpy_version = package.version
opencv_version = ""
# dig the version from OpenCV sources
version_file_path = "opencv/modules/core/include/opencv2/core/version.hpp"
with open(version_file_path, 'r') as f:
for line in f:
words = line.split()
if "CV_VERSION_MAJOR" in words:
opencv_version += words[2]
opencv_version += "."
if "CV_VERSION_MINOR" in words:
opencv_version += words[2]
opencv_version += "."
if "CV_VERSION_REVISION" in words:
opencv_version += words[2]
break
class BinaryDistribution(Distribution):
""" Forces BinaryDistribution. """
def has_ext_modules(asd):
return True
package_data = {}
if os.name == 'posix':
package_data['cv2'] = ['*.so']
else:
package_data['cv2'] = ['*.pyd']
setup(name='opencv-python',
version=opencv_version,
description='OpenCV',
distclass=BinaryDistribution,
packages=['cv2'],
package_data=package_data,
install_requires="numpy==%s" % numpy_version,
)