forked from dmlc/gluon-cv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
117 lines (100 loc) · 2.8 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
#!/usr/bin/env python
import io
import os
import re
import sys
try:
from Cython.Build import cythonize
except ImportError:
cythonize = None
from setuptools import setup, find_packages, Extension
try:
import cv2
except ImportError:
cv2 = None
with_cython = False
if '--with-cython' in sys.argv:
if not cythonize:
print("Cython not found, please run `pip install Cython`")
exit(1)
with_cython = True
sys.argv.remove('--with-cython')
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()
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.")
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except(IOError, ImportError):
long_description = open('README.md').read()
VERSION = find_version('gluoncv', '__init__.py')
requirements = [
'numpy',
'tqdm',
'requests',
# 'mxnet',
'matplotlib',
'portalocker',
'Pillow',
'scipy',
#'tensorboardx',
#'decord',
#'opencv-python',
'yacs',
'pandas',
'pyyaml',
'autocfg',
#'autogluon.core'
]
# do not duplicate opencv module if already compiled from source
if cv2 is None:
requirements.append('opencv-python')
extra_requirements = {
'full': ['tensorboardx', 'decord', 'autogluon.core', 'cython', 'pycocotools'],
'auto': ['autogluon.core']
}
if with_cython:
import numpy as np
_NP_INCLUDE_DIRS = np.get_include()
# Extension modules
ext_modules = cythonize([
Extension(
name='gluoncv.nn.cython_bbox',
sources=['gluoncv/nn/cython_bbox.pyx'],
extra_compile_args=['-Wno-cpp', '-O3'],
include_dirs=[_NP_INCLUDE_DIRS]),
Extension(
name='gluoncv.model_zoo.rcnn.rpn.cython_rpn_target',
sources=['gluoncv/model_zoo/rcnn/rpn/cython_rpn_target.pyx'],
extra_compile_args=['-Wno-cpp', '-O3'],
include_dirs=[_NP_INCLUDE_DIRS]),
])
else:
ext_modules = []
setup(
# Metadata
name='gluoncv',
version=VERSION,
author='Gluon CV Toolkit Contributors',
url='https://github.com/dmlc/gluon-cv',
description='MXNet Gluon CV Toolkit',
long_description=long_description,
license='Apache-2.0',
# Package info
packages=find_packages(exclude=('docs', 'tests', 'scripts')),
zip_safe=True,
include_package_data=True,
install_requires=requirements,
ext_modules=ext_modules,
extras_require=extra_requirements
)