-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
210 lines (181 loc) · 7.44 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#! /usr/bin/env python
#
# Copyright (C) 2020-2024 T. Moudiki <[email protected]>
# License: 3-clause BSD
import subprocess
import sys
subprocess.run(['pip', 'install', 'numpy'], check=False)
subprocess.run(['pip', 'install', 'scipy'], check=False)
subprocess.run(['pip', 'install', 'requests'], check=False)
subprocess.run(['pip', 'install', 'Cython'], check=False)
import os
import platform
import setuptools
import shutil
from os import path
from pathlib import Path
from setuptools import Extension, find_packages, setup
try:
import builtins
except ImportError:
import __builtin__ as builtins
import numpy
from Cython.Build import cythonize
builtins.__MLSAUCE_SETUP__ = True
DISTNAME = 'mlsauce'
DESCRIPTION = 'Miscellaneous Statistical/Machine Learning tools'
LONG_DESCRIPTION = 'Miscellaneous Statistical/Machine Learning tools'
MAINTAINER = 'T. Moudiki'
MAINTAINER_EMAIL = '[email protected]'
LICENSE = 'BSD3 Clause Clear'
__version__ = '0.24.0'
VERSION = __version__
if platform.python_implementation() == 'PyPy':
SCIPY_MIN_VERSION = '1.1.0'
NUMPY_MIN_VERSION = '1.14.0'
else:
SCIPY_MIN_VERSION = '0.19.0'
NUMPY_MIN_VERSION = '1.13.0'
JOBLIB_MIN_VERSION = '1.2.0'
SKLEARN_MIN_VERSION = '0.18.0'
THREADPOOLCTL_MIN_VERSION = '2.0.0'
PANDAS_MIN_VERSION = '0.25.3'
QUERIER_MIN_VERSION = '0.4.0'
REQUESTS_MIN_VERSION = '2.31.0'
if platform.system() in ('Linux', 'Darwin'):
JAX_MIN_VERSION = '0.1.72'
JAXLIB_MIN_VERSION = '0.1.51'
SETUPTOOLS_COMMANDS = {
'develop', 'release', 'bdist_egg', 'bdist_rpm',
'bdist_wininst', 'install_egg_info', 'build_sphinx',
'egg_info', 'easy_install', 'upload', 'bdist_wheel',
'--single-version-externally-managed',
}
if SETUPTOOLS_COMMANDS.intersection(sys.argv):
extra_setuptools_args = dict(
zip_safe=False, # the package can run out of an .egg file
include_package_data=True,
extras_require={
'alldeps': (
'numpy >= {}'.format(NUMPY_MIN_VERSION),
'scipy >= {}'.format(SCIPY_MIN_VERSION),
),
},
)
else:
extra_setuptools_args = dict()
WHEELHOUSE_UPLOADER_COMMANDS = {'fetch_artifacts', 'upload_all'}
if WHEELHOUSE_UPLOADER_COMMANDS.intersection(sys.argv):
import wheelhouse_uploader.cmd
cmdclass.update(vars(wheelhouse_uploader.cmd))
ext_modules =[
Extension(name="mlsauce.adaopt._adaoptc",
library_dirs=["mlsauce/adaopt/"],
runtime_library_dirs=["mlsauce/adaopt/"],
sources=["mlsauce/adaopt/_adaoptc.pyx"],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.booster._boosterc",
library_dirs=["mlsauce/booster/"],
runtime_library_dirs=["mlsauce/booster/"],
sources=["mlsauce/booster/_boosterc.pyx"],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.lasso._lassoc",
library_dirs=["mlsauce/lasso/"],
runtime_library_dirs=["mlsauce/lasso/"],
sources=["mlsauce/lasso/_lassoc.pyx"],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.ridge._ridgec",
library_dirs=["mlsauce/ridge/"],
runtime_library_dirs=["mlsauce/ridge/"],
sources=["mlsauce/ridge/_ridgec.pyx"],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.stump._stumpc",
library_dirs=["mlsauce/stump/"],
runtime_library_dirs=["mlsauce/stump/"],
sources=["mlsauce/stump/_stumpc.pyx"],
include_dirs=[numpy.get_include()]),
]
# Get the absolute path to the directory containing the setup script
abs_path = os.path.dirname(__file__)
rel_path = os.path.relpath(abs_path)
script_dir = rel_path
# Get absolute paths to Cython source files
adaopt_cython_file = str(script_dir + 'mlsauce/adaopt/_adaoptc.pyx')
booster_cython_file = str(script_dir + 'mlsauce/booster/_boosterc.pyx')
lasso_cython_file = str(script_dir + 'mlsauce/lasso/_lassoc.pyx')
ridge_cython_file = str(script_dir + 'mlsauce/ridge/_ridgec.pyx')
stump_cython_file = str(script_dir + 'mlsauce/stump/_stumpc.pyx')
# Update Extension definitions with absolute paths
ext_modules2 = [
Extension(name="mlsauce.adaopt._adaoptc",
sources=[adaopt_cython_file],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.booster._boosterc",
sources=[booster_cython_file],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.lasso._lassoc",
sources=[lasso_cython_file],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.ridge._ridgec",
sources=[ridge_cython_file],
include_dirs=[numpy.get_include()]),
Extension(name="mlsauce.stump._stumpc",
sources=[stump_cython_file],
include_dirs=[numpy.get_include()]),
]
def setup_package():
install_all_requires = [
"numpy",
"Cython",
"joblib",
"matplotlib",
"nnetsauce",
"pandas",
"requests",
"scikit-learn",
"scipy",
"tqdm"
]
# if platform.system() in ('Linux', 'Darwin'):
# install_jax_requires = ['jax', 'jaxlib']
# else:
# install_jax_requires = []
# install_requires = [item for sublist in [install_all_requires, install_jax_requires] for item in sublist]
install_requires = install_all_requires
try:
cythonize_ext_modules = cythonize(ext_modules2, annotate=True)
except:
cythonize_ext_modules = cythonize(ext_modules, annotate=True)
metadata = dict(name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
version=VERSION,
long_description=LONG_DESCRIPTION,
classifiers=['Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
platforms=["linux", "macosx", "windows"],
python_requires=">=3.5",
install_requires=install_requires,
setup_requires=["numpy>= 1.13.0"],
package_data={'': ['*.pxd']},
packages=find_packages(),
ext_modules=cythonize_ext_modules,
**extra_setuptools_args)
setup(**metadata)
if __name__ == "__main__":
setup_package()
dir_path = os.path.dirname(os.path.realpath(__file__))
folders = ['adaopt', 'booster', 'elasticnet', 'lasso', 'ridge', 'stump']
for folder in folders:
filename = os.path.join(dir_path, "mlsauce", folder, 'setup2.py')
subprocess.run(['python3', filename, 'build_ext', '--inplace'])