forked from scikit-garden/scikit-garden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
85 lines (70 loc) · 2.57 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
#! /usr/bin/env python
import os
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
DISTNAME = "scikit-garden"
DESCRIPTION = "A garden of scikit-learn compatible trees"
URL = "https://github.com/scikit-garden/scikit-garden"
MAINTAINER = "Manoj Kumar"
MAINTAINER_EMAIL = "[email protected]"
LICENSE = "new BSD"
VERSION = "0.1.3"
libraries = []
if os.name == "posix":
libraries.append("m")
extensions = []
for name in ["_tree", "_splitter", "_criterion", "_utils"]:
extensions.append(
Extension(
"skgarden.mondrian.tree.{}".format(name),
sources=["skgarden/mondrian/tree/{}.pyx".format(name)],
libraries=libraries,
extra_compile_args=["-O3"],
)
)
class CustomBuildExtCommand(build_ext):
"""build_ext command for use when numpy headers are needed."""
def run(self):
# Import numpy here, only when headers are needed
import numpy
# Add numpy headers to include_dirs
self.include_dirs.append(numpy.get_include())
super().run()
def finalize_options(self):
# Import Cython here, only when we need to cythonize extensions
if self.distribution.ext_modules:
from Cython.Build.Dependencies import cythonize
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules, force=self.force
)
super().finalize_options()
if __name__ == "__main__":
setup(
name=DISTNAME,
cmdclass={"build_ext": CustomBuildExtCommand},
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
packages=find_packages(),
include_package_data=True,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=VERSION,
zip_safe=False, # the package can run out of an .egg file
classifiers=[
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: C",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
],
install_requires=["numpy", "scipy", "scikit-learn>=0.22", "six"],
setup_requires=["Cython>=0.23,<3.0.0", "numpy", "setuptools>=18"],
ext_modules=extensions,
)