forked from nanshe-org/rank_filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
130 lines (111 loc) · 4.17 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
118
119
120
121
122
123
124
125
126
127
128
129
130
import os
import sys
from glob import glob
import setuptools
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext
from distutils.sysconfig import get_config_var, get_python_inc
from distutils.version import LooseVersion
import versioneer
assert LooseVersion(setuptools.__version__) >= LooseVersion("18.0"), \
"Requires `setuptools` version 18.0 or higher."
class build_ext(_build_ext):
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 readme():
with open("README.rst", "r") as f:
return(f.read())
version = versioneer.get_version()
with open("src/version.pxi", "w") as f:
f.writelines([
"__version__ = " + "\"" + str(version) + "\""
])
cython_dep = ["cython >= 0.23"]
numpy_dep = ["numpy >= 1.7"]
boost_dep = ["boost-cpp >= 1.56"]
boost_dep = (boost_dep if sys.argv[1] == "bdist_conda" else [])
setup_requires = cython_dep + numpy_dep
setup_requires = setup_requires if (sys.argv[1].startswith("bdist") or
sys.argv[1].startswith("build") or
sys.argv[1].startswith("install")) else []
build_requires = cython_dep + numpy_dep + boost_dep
install_requires = numpy_dep + boost_dep
install_requires += [] if sys.argv[1] == "bdist_conda" else cython_dep
tests_require = cython_dep + numpy_dep
include_dirs = [
os.path.join(os.path.dirname(os.path.abspath(__file__)), "include"),
os.path.dirname(get_python_inc()),
get_python_inc()
]
library_dirs = list(filter(
lambda v: v is not None,
[get_config_var("LIBDIR")]
))
sources = glob("src/*.pxd") + glob("src/*.pyx")
libraries = []
if os.name == "posix":
libraries.append("boost_container")
elif os.name == "nt":
libname = "boost_container"
path = os.environ.get("LIB", "").split(";")
libmatches = sum(
list(glob(os.path.join(p, "%s*.lib" % libname)) for p in path), []
)
library_dirs.append(os.path.dirname(libmatches[0]))
libraries.append(os.path.splitext(os.path.basename(libmatches[0]))[0])
extra_compile_args = []
setup(
name="rank_filter",
version=version,
description="A simple python module containing an in-place linear rank"
" filter optimized in C++.",
long_description=readme(),
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Programming Language :: C++',
'Programming Language :: Cython',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries'
],
author="John Kirkham",
author_email="[email protected]",
url="https://github.com/nanshe-org/rank_filter",
download_url="https://github.com/nanshe-org/rank_filter/archive/v%s.tar.gz"
% version,
license="BSD",
cmdclass=dict(
list(versioneer.get_cmdclass().items()) +
[
('build_ext', build_ext)
]
),
setup_requires=setup_requires,
build_requires=build_requires,
install_requires=install_requires,
tests_require=tests_require,
test_suite="tests",
headers=glob("include/*.hxx"),
ext_modules=[Extension("rank_filter",
sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
language="c++")],
zip_safe=False
)