|
import os |
|
import io |
|
from subprocess import check_output |
|
from pkg_resources import require |
|
from setuptools import setup, find_packages |
|
|
|
with io.open('opencv/modules/core/include/opencv2/core/version.hpp', encoding="utf-8") as f: |
|
opencv_version = "" |
|
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 |
|
git_tag = int(check_output([ |
|
'git', 'name-rev', '--tags', '--name-only', 'HEAD' |
|
]).splitlines()[0].decode()) |
|
opencv_version += ".{}".format(git_tag) |
|
if git_tag >= 13: |
|
headless_build = bool(int(os.getenv('ENABLE_HEADLESS', '0'))) |
|
else: |
|
headless_build = False |
|
contrib_build = bool(int(os.getenv('ENABLE_CONTRIB', '0'))) |
|
numpy_version = require('numpy')[0].version |
|
package_name = "opencv{contrib}-python{headless}".format( |
|
contrib="-contrib" if contrib_build else "", |
|
headless="-headless" if headless_build else "") |
|
package_data = { |
|
'': ['*.xml'], |
|
'cv2': ['*.so', 'LICENSE.txt', 'LICENSE-3RD-PARTY.txt'], |
|
} |
|
if git_tag < 13: |
|
if contrib_build: |
|
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() |
|
else: |
|
with io.open('README.md', encoding="utf-8") as f: |
|
long_description = f.read() |
|
|
|
print(opencv_version) |
|
print(numpy_version) |
|
print(package_name) |
|
print(repr(package_data)) |
|
|
|
# This creates a list which is empty but returns a length of 1. |
|
# Should make the wheel a binary distribution and platlib compliant. |
|
class EmptyListWithLength(list): |
|
def __len__(self): |
|
return 1 |
|
|
|
|
|
setup(name=package_name, |
|
version=opencv_version, |
|
url='https://github.com/skvark/opencv-python', |
|
license='MIT', |
|
description='Wrapper package for OpenCV python bindings.', |
|
long_description=long_description, |
|
packages=find_packages(), |
|
package_data=package_data, |
|
maintainer="Olli-Pekka Heinisuo", |
|
include_package_data=True, |
|
ext_modules=EmptyListWithLength(), |
|
install_requires="numpy>=%s" % numpy_version, |
|
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 :: 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', |
|
'Programming Language :: C++', |
|
'Programming Language :: Python :: Implementation :: CPython', |
|
'Topic :: Scientific/Engineering', |
|
'Topic :: Scientific/Engineering :: Image Recognition', |
|
'Topic :: Software Development', |
|
] |
|
) |