-
Notifications
You must be signed in to change notification settings - Fork 53
/
setup.py
executable file
·65 lines (58 loc) · 2.11 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
#!/usr/bin/env python
"""
Implements the MDLP discretization criterion from Usama Fayyad's paper
"Multi-Interval Discretization of Continuous-Valued Attributes for
Classification Learning."
"""
from setuptools import Extension, find_packages, setup
if __name__ == '__main__':
# see https://stackoverflow.com/a/42163080 for the approach to pushing
# numpy and cython dependencies into extension building only
try:
# if Cython is available, we will rebuild from the pyx file directly
from Cython.Distutils import build_ext
print("Using cython to build the extension")
sources = ['mdlp/_mdlp.pyx']
except:
# else we build from the cpp file included in the distribution
print("Cannot find available cython installation. Using cpp to build the extension")
from setuptools.command.build_ext import build_ext
sources = ['mdlp/_mdlp.cpp']
class CustomBuildExt(build_ext):
"""Custom build_ext class to defer numpy imports until needed.
Overrides the run command for building an extension and adds in numpy
include dirs to the extension build. Doing this at extension build time
allows us to avoid requiring that numpy be pre-installed before
executing this setup script.
"""
def run(self):
import numpy
self.include_dirs.append(numpy.get_include())
build_ext.run(self)
cpp_ext = Extension(
'mdlp._mdlp',
sources=sources,
libraries=[],
include_dirs=[],
language='c++',
)
setup(
name='mdlp-discretization',
version='0.3.3',
description=__doc__,
license='BSD 3 Clause',
url='github.com/hlin117/mdlp-discretization',
author='Henry Lin',
author_email='[email protected]',
install_requires=[
'numpy>=1.11.2',
'scipy>=0.18.1',
'scikit-learn>=0.18.1',
],
setup_requires=[
'numpy>=1.11.2',
],
packages=['mdlp'],
ext_modules=[cpp_ext],
cmdclass={'build_ext': CustomBuildExt},
)