forked from Borda/pyImSegm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
115 lines (98 loc) · 3.75 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
"""
The build/compilations setup
>> pip install -r requirements.txt
>> python setup.py build_ext --inplace
>> python setup.py install
For uploading to PyPi follow instructions
http://peterdowns.com/posts/first-time-with-pypi.html
Pre-release package
>> python setup.py sdist upload -r pypitest
>> pip install --index-url https://test.pypi.org/simple/ your-package
Release package
>> python setup.py sdist upload -r pypi
>> pip install your-package
Copyright (C) 2014-2017 Jiri Borovec <jiri.borovec@fel.cvut.cz>
"""
import os
import sys
try:
from setuptools import Extension, setup # , find_packages, Command
from setuptools.command.build_ext import build_ext
except ImportError:
from distutils.core import setup, Extension # , find_packages, Command
from distutils.command.build_ext import build_ext
import imsegm
# from Cython.Distutils import build_ext
# from Cython.Build import cythonize
# extensions = [Extension("*", "*.pyx")]
TEMP_EGG = '#egg='
HERE = os.path.abspath(os.path.dirname(__file__))
class BuildExt(build_ext):
""" build_ext command for use when numpy headers are needed.
SEE tutorial: https://stackoverflow.com/questions/2379898
SEE fix: https://stackoverflow.com/questions/19919905
"""
def finalize_options(self):
build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
# __builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
def _parse_requirements(file_path):
with open(file_path) as fp:
reqs = [r.rstrip() for r in fp.readlines() if not r.startswith('#')]
# drop all proprietary packages missing from PiPy
reqs = filter(lambda r: not r.startswith('http'), reqs)
# parse egg names if there are paths
reqs = [r[r.index(TEMP_EGG) + len(TEMP_EGG):] if TEMP_EGG in r else r for r in reqs]
return reqs
if sys.version_info.major == 2:
# numpy v1.17 drops support for py2
setup_reqs = ['Cython', 'numpy<1.17']
install_reqs = _parse_requirements(os.path.join(HERE, 'require-py27.txt'))
else:
setup_reqs = ['Cython', 'numpy']
install_reqs = _parse_requirements(os.path.join(HERE, 'requirements.txt'))
setup(
name='ImSegm',
version=imsegm.__version__,
url=imsegm.__homepage__,
author=imsegm.__author__,
author_email=imsegm.__author_email__,
license=imsegm.__license__,
description=imsegm.__doc__,
keywords='image segmentation region-growing center-detection ellipse-fitting',
long_description=imsegm.__long_doc__,
long_description_content_type='text/markdown',
packages=['imsegm', 'imsegm.utilities'],
cmdclass={'build_ext': BuildExt},
ext_modules=[
Extension(
'imsegm.features_cython',
language='c++',
sources=['imsegm/features_cython.pyx'],
extra_compile_args=['-O3', '-ffast-math', '-march=native'],
# extra_link_args=['-fopenmp'],
)
],
setup_requires=setup_reqs,
install_requires=install_reqs,
# include_dirs = [np.get_include()],
include_package_data=True,
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Image Segmentation",
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
)