setup.py 2.8 KB
Newer Older
O
Olli-Pekka Heinisuo 已提交
1
from setuptools import setup
2 3
from setuptools.dist import Distribution
import pip
O
Olli-Pekka Heinisuo 已提交
4 5
import os
import sys
6
import io
7

8 9 10
# cv_version.py should be generated by running find_version.py
from cv_version import opencv_version

11 12
contrib_build = False
package_name = "opencv-python"
13 14 15
numpy_version = ""
long_description = ""
package_data = {}
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30
contrib = os.getenv('ENABLE_CONTRIB', None)

if contrib is not None:
    if int(contrib) == 1:
        contrib_build = True
else:
    try:
        print("Trying to read contrib enable flag from file...")
        with open("contrib.enabled") as f:
            flag = int(f.read(1))
            if flag == 1:
                contrib_build = True
    except:
        pass
31

32
# Use different README and package name for contrib build.
33 34
if contrib_build:
    package_name = "opencv-contrib-python"
35 36 37 38 39
    with io.open('README_CONTRIB.rst', encoding="utf-8") as f:
        long_description = f.read()
else:
    with io.open('README.rst', encoding="utf-8") as f:
        long_description = f.read()
40 41 42 43 44 45

# Get required numpy version
for package in pip.get_installed_distributions():
    if package.key == "numpy":
        numpy_version = package.version

46 47 48 49 50
if os.name == 'posix':
    package_data['cv2'] = ['*.so']
else:
    package_data['cv2'] = ['*.pyd', '*.dll']

J
Jon Winsley 已提交
51
package_data['cv2'] += ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]
52

53 54
class BinaryDistribution(Distribution):
    """ Forces BinaryDistribution. """
O
Olli-Pekka Heinisuo 已提交
55
    def has_ext_modules(self):
56 57
        return True

58 59 60
    def is_pure(self):
        return False

61
setup(name=package_name,
O
Olli-Pekka Heinisuo 已提交
62
      version=opencv_version,
63 64 65
      url='https://github.com/skvark/opencv-python',
      license='MIT',
      description='Wrapper package for OpenCV python bindings.',
66
      long_description=long_description,
67
      distclass=BinaryDistribution,
O
Olli-Pekka Heinisuo 已提交
68 69
      packages=['cv2'],
      package_data=package_data,
70 71
      maintainer="Olli-Pekka Heinisuo",
      include_package_data=True,
72
      install_requires="numpy>=%s" % numpy_version,
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
      classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Environment :: Console',
        'Intended Audience :: Developers',
        'Intended Audience :: Education',
        'Intended Audience :: Information Technology',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Operating System :: MacOS',
        'Operating System :: Microsoft :: Windows',
        'Operating System :: POSIX',
        'Operating System :: Unix',
        'Programming Language :: Python',
        'Programming Language :: C++',
        'Programming Language :: Python :: Implementation :: CPython',
        'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Image Recognition',
        'Topic :: Software Development',
        ]
92
      )