setup.py 2.36 KB
Newer Older
Kai Chen's avatar
Kai Chen committed
1
import platform
2
import sys
3
from io import open  # for Python 2 (identical to builtin in Python 3)
4
5
6
7
from setuptools import Extension, find_packages, setup

import numpy
from Cython.Distutils import build_ext
8

Kai Chen's avatar
Kai Chen committed
9
install_requires = [
10
11
    'numpy>=1.11.1', 'pyyaml', 'six', 'addict', 'requests', 'opencv-python',
    'Cython'
Kai Chen's avatar
Kai Chen committed
12
]
13
14
15
16
17
18
19
if sys.version_info < (3, 3):
    install_requires.append('backports.shutil_get_terminal_size')
if sys.version_info < (3, 4):
    install_requires.extend(['enum34', 'pathlib'])


def readme():
20
    with open('README.rst', encoding='utf-8') as f:
21
22
23
24
25
26
        content = f.read()
    return content


def get_version():
    version_file = 'mmcv/version.py'
27
    with open(version_file, 'r', encoding='utf-8') as f:
28
29
30
31
        exec(compile(f.read(), version_file, 'exec'))
    return locals()['__version__']


Kai Chen's avatar
Kai Chen committed
32
33
34
35
36
37
38
if platform.system() == 'Darwin':
    extra_compile_args = ['-stdlib=libc++']
    extra_link_args = ['-stdlib=libc++']
else:
    extra_compile_args = []
    extra_link_args = []

39
40
41
42
43
44
45
EXT_MODULES = [
    Extension(
        name='mmcv._ext',
        sources=[
            './mmcv/video/optflow_warp/flow_warp.cpp',
            './mmcv/video/optflow_warp/flow_warp_module.pyx'
        ],
46
        include_dirs=[numpy.get_include()],
Kai Chen's avatar
Kai Chen committed
47
48
49
        language='c++',
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
50
51
52
    ),
]

53
54
55
56
57
58
59
60
61
setup(
    name='mmcv',
    version=get_version(),
    description='Open MMLab Computer Vision Foundation',
    long_description=readme(),
    keywords='computer vision',
    packages=find_packages(),
    classifiers=[
        'Development Status :: 4 - Beta',
Kai Chen's avatar
Kai Chen committed
62
        'License :: OSI Approved :: Apache Software License',
63
64
65
66
67
68
69
        'Operating System :: OS Independent',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
70
        'Programming Language :: Python :: 3.7',
71
72
73
74
75
76
77
78
        'Topic :: Utilities',
    ],
    url='https://github.com/open-mmlab/mmcv',
    author='Kai Chen',
    author_email='chenkaidev@gmail.com',
    setup_requires=['pytest-runner'],
    tests_require=['pytest'],
    install_requires=install_requires,
79
80
    ext_modules=EXT_MODULES,
    cmdclass={'build_ext': build_ext},
81
    zip_safe=False)