-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathsetup.py
executable file
·131 lines (109 loc) · 4.06 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
131
#! /usr/bin/env python
"""scikit-learn compatible quantile forests."""
import builtins
import codecs
import os
import sys
from setuptools import find_packages, setup
# Setting a global variable so that the main package __init__ can detect if it
# is being loaded by the setup routine.
builtins.__QF_SETUP__ = True
import quantile_forest._min_dependencies as min_deps # noqa
def write_version_py():
with open(os.path.join("quantile_forest", "version.txt")) as f:
version = f.read().strip()
with open(os.path.join("quantile_forest", "version.py"), "w") as f:
f.write(f'__version__ = "{version}"\n')
return version
__version__ = write_version_py()
DISTNAME = "quantile-forest"
DESCRIPTION = "Quantile regression forests compatible with scikit-learn."
with codecs.open("README.md", encoding="utf-8-sig") as f:
LONG_DESCRIPTION = f.read()
MAINTAINER = "Zillow Group AI Team"
LICENSE = "Apache License 2.0"
URL = "https://zillow.github.io/quantile-forest"
DOWNLOAD_URL = "https://pypi.org/project/quantile-forest/#files"
PROJECT_URLS = {
"Documentation": "https://zillow.github.io/quantile-forest",
"Source": "https://github.com/zillow/quantile-forest",
"Tracker": "https://github.com/zillow/quantile-forest/issues",
}
VERSION = __version__
CLASSIFIERS = [
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
]
def configure_extension_modules():
# Skip cythonization as we do not want to include the generated
# C/C++ files in the release tarballs as they are not necessarily
# forward compatible with future versions of Python for instance.
if "sdist" in sys.argv or "--help" in sys.argv:
return []
import numpy
from Cython.Build import cythonize
from setuptools.extension import Extension
# For building Cython extensions.
EXTENSIONS = [
Extension(
"quantile_forest._quantile_forest_fast",
sources=["quantile_forest/_quantile_forest_fast.pyx"],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
include_dirs=[numpy.get_include()],
language="c++",
),
Extension(
"quantile_forest._utils",
sources=["quantile_forest/_utils.pyx"],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
include_dirs=[numpy.get_include()],
language="c++",
),
]
return cythonize(
EXTENSIONS,
compiler_directives={
"language_level": "3",
"boundscheck": False,
"cdivision": True,
"initializedcheck": False,
"nonecheck": False,
"wraparound": False,
},
)
def setup_package():
metadata = dict(
name=DISTNAME,
maintainer=MAINTAINER,
description=DESCRIPTION,
license=LICENSE,
url=URL,
download_url=DOWNLOAD_URL,
project_urls=PROJECT_URLS,
version=VERSION,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
zip_safe=False, # the package can run out of an .egg file
classifiers=CLASSIFIERS,
packages=find_packages(),
install_requires=min_deps.tag_to_packages["install"],
)
commands = [arg for arg in sys.argv[1:] if not arg.startswith("-")]
if not all(command in ("egg_info", "dist_info", "clean", "check") for command in commands):
metadata["ext_modules"] = configure_extension_modules()
setup(**metadata)
if __name__ == "__main__":
setup_package()