forked from Mathics3/mathics-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
269 lines (233 loc) · 7.99 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Python Setuptools for Mathics core
For the easiest installation:
pip install -e .
For full installation:
pip install -e .[full]
This will install the library in the default location. For instructions on
how to customize the install procedure read the output of:
python setup.py --help install
In addition, there are some other commands:
python setup.py clean -> will clean all trash (*.pyc and stuff)
To get a full list of avaiable commands, read the output of:
python setup.py --help-commands
"""
import os
import os.path as osp
import platform
import re
import sys
from setuptools import Extension, setup
is_PyPy = platform.python_implementation() == "PyPy" or hasattr(
sys, "pypy_version_info"
)
INSTALL_REQUIRES = [
"Mathics-Scanner >= 1.3.0.dev0",
# Pillow 9.1.0 supports BigTIFF with big-endian byte order.
# ExampleData image hedy.tif is in this format.
# Pillow 9.2 handles sunflowers.jpg
]
# Ensure user has the correct Python version
# Address specific package dependencies based on Python version
if sys.version_info < (3, 6):
print("Mathics does not support Python %d.%d" % sys.version_info[:2])
sys.exit(-1)
elif sys.version_info[:2] == (3, 6):
INSTALL_REQUIRES += [
"recordclass",
"numpy",
"llvmlite<0.37",
"pillow >= 8.4.0",
"sympy>=1.8,<1.12",
]
if is_PyPy:
print("Mathics does not support PyPy Python 3.6" % sys.version_info[:2])
sys.exit(-1)
else:
INSTALL_REQUIRES += ["numpy<=1.24", "llvmlite", "sympy>=1.8, < 1.12"]
# if not is_PyPy:
# INSTALL_REQUIRES += ["recordclass"]
def get_srcdir():
filename = osp.normcase(osp.dirname(osp.abspath(__file__)))
return osp.realpath(filename)
def read(*rnames):
return open(osp.join(get_srcdir(), *rnames)).read()
long_description = read("README.rst") + "\n"
# stores __version__ in the current namespace
exec(compile(open("mathics/version.py").read(), "mathics/version.py", "exec"))
EXTRAS_REQUIRE = {}
for kind in ("dev", "full", "cython"):
extras_require = []
requirements_file = f"requirements-{kind}.txt"
for line in open(requirements_file).read().split("\n"):
if line and not line.startswith("#"):
requires = re.sub(r"([^#]+)(\s*#.*$)?", r"\1", line)
extras_require.append(requires)
EXTRAS_REQUIRE[kind] = extras_require
DEPENDENCY_LINKS = []
# "http://github.com/Mathics3/mathics-scanner/tarball/master#egg=Mathics_Scanner-1.0.0.dev"
# ]
# What should be run through Cython?
EXTENSIONS = []
CMDCLASS = {}
try:
if is_PyPy:
raise ImportError
from Cython.Distutils import build_ext
except ImportError:
pass
else:
if os.environ.get("USE_CYTHON", False):
print("Running Cython over code base")
EXTENSIONS_DICT = {
"core": (
"expression",
"symbols",
"number",
"rules",
"pattern",
),
"builtin": ["arithmetic", "patterns", "graphics"],
"eval": ("nevaluator", "makeboxes", "test"),
}
EXTENSIONS = [
Extension(
"mathics.%s.%s" % (parent, module),
["mathics/%s/%s.py" % (parent, module)],
)
for parent, modules in EXTENSIONS_DICT.items()
for module in modules
]
# EXTENSIONS_SUBDIR_DICT = {
# "builtin": [("numbers", "arithmetic"), ("numbers", "numeric"), ("drawing", "graphics")],
# }
# EXTENSIONS.append(
# Extension(
# "mathics.%s.%s.%s" % (parent, module[0], module[1]), ["mathics/%s/%s/%s.py" % (parent, module[0], module[1])]
# )
# for parent, modules in EXTENSIONS_SUBDIR_DICT.items()
# for module in modules
# )
CMDCLASS = {"build_ext": build_ext}
INSTALL_REQUIRES += ["cython>=0.15.1"]
# General Requirements
INSTALL_REQUIRES += [
"mpmath>=1.2.0",
"palettable",
"pint",
"python-dateutil",
"requests",
"setuptools",
]
print(f'Installation requires "{", ".join(INSTALL_REQUIRES)}')
def subdirs(root, file="*.*", depth=10):
for k in range(depth):
yield root + "*/" * k + file
setup(
name="Mathics3",
cmdclass=CMDCLASS,
ext_modules=EXTENSIONS,
version=__version__,
packages=[
"mathics",
"mathics.algorithm",
"mathics.compile",
"mathics.core",
"mathics.core.convert",
"mathics.core.parser",
"mathics.builtin",
"mathics.builtin.arithfns",
"mathics.builtin.assignments",
"mathics.builtin.atomic",
"mathics.builtin.binary",
"mathics.builtin.box",
"mathics.builtin.colors",
"mathics.builtin.distance",
"mathics.builtin.exp_structure",
"mathics.builtin.drawing",
"mathics.builtin.fileformats",
"mathics.builtin.files_io",
"mathics.builtin.forms",
"mathics.builtin.functional",
"mathics.builtin.image",
"mathics.builtin.intfns",
"mathics.builtin.list",
"mathics.builtin.matrices",
"mathics.builtin.numbers",
"mathics.builtin.numpy_utils",
"mathics.builtin.pymimesniffer",
"mathics.builtin.pympler",
"mathics.builtin.quantum_mechanics",
"mathics.builtin.scipy_utils",
"mathics.builtin.specialfns",
"mathics.builtin.statistics",
"mathics.builtin.string",
"mathics.builtin.testing_expressions",
"mathics.builtin.vectors",
"mathics.eval",
"mathics.doc",
"mathics.format",
],
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
dependency_links=DEPENDENCY_LINKS,
package_data={
"mathics": [
"data/*.csv",
"data/*.json",
"data/*.yml",
"data/*.yaml",
"data/*.pcl",
"data/ExampleData/*",
"doc/xml/data",
"doc/tex/data",
"autoload/*.m",
"autoload-cli/*.m",
"autoload/formats/*/Import.m",
"autoload/formats/*/Export.m",
"packages/*/*.m",
"packages/*/Kernel/init.m",
"requirements-cython.txt",
"requirements-full.txt",
],
"mathics.doc": ["documentation/*.mdoc", "xml/data"],
"mathics.builtin.pymimesniffer": ["mimetypes.xml"],
"pymathics": ["doc/documentation/*.mdoc", "doc/xml/data"],
},
entry_points={
"console_scripts": [
"mathics = mathics.main:main",
],
},
long_description=long_description,
long_description_content_type="text/x-rst",
# don't pack Mathics in egg because of media files, etc.
zip_safe=False,
# metadata for upload to PyPI
maintainer="Mathics Group",
maintainer_email="[email protected]",
description="A general-purpose computer algebra system.",
license="GPL",
url="https://mathics.org/",
download_url="https://github.com/Mathics/mathics-core/releases",
keywords=["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"],
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Interpreters",
],
# TODO: could also include long_description, download_url,
)