Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sympy
GitHub Repository: sympy/sympy
Path: blob/master/setup.py
2046 views
1
#!/usr/bin/env python
2
"""Setup script for SymPy.
3
4
This uses Setuptools (https://setuptools.pypa.io/en/latest/) the standard
5
python mechanism for installing packages.
6
For the easiest installation just type the command (you'll probably need
7
root privileges for that):
8
9
pip install .
10
11
This will install the library in the default location. For instructions on
12
how to customize the installation procedure read the output of:
13
14
pip install --help
15
16
In addition, there are some other commands:
17
18
python setup.py test -> will run the complete test suite
19
20
To get a full list of available commands, read the output of:
21
22
python setup.py --help-commands
23
24
Or, if all else fails, feel free to write to the sympy list at
25
[email protected] and ask for help.
26
"""
27
28
import sys
29
import os
30
import subprocess
31
from pathlib import Path
32
33
from setuptools import setup, Command
34
from setuptools.command.sdist import sdist
35
36
37
# This directory
38
dir_setup = os.path.dirname(os.path.realpath(__file__))
39
40
extra_kwargs = {
41
'zip_safe': False,
42
'entry_points': {
43
'console_scripts': [
44
'isympy = isympy:main',
45
]
46
}
47
}
48
49
# Keep in sync with sympy/__init__.py and python_requires below
50
if sys.version_info < (3, 9):
51
print("SymPy requires Python 3.9 or newer. Python %d.%d detected"
52
% sys.version_info[:2])
53
sys.exit(-1)
54
55
# Check that this list is uptodate against the result of the command:
56
# python bin/generate_module_list.py
57
modules = [
58
'sympy.algebras',
59
'sympy.assumptions',
60
'sympy.assumptions.handlers',
61
'sympy.assumptions.predicates',
62
'sympy.assumptions.relation',
63
'sympy.benchmarks',
64
'sympy.calculus',
65
'sympy.categories',
66
'sympy.codegen',
67
'sympy.combinatorics',
68
'sympy.concrete',
69
'sympy.core',
70
'sympy.core.benchmarks',
71
'sympy.crypto',
72
'sympy.diffgeom',
73
'sympy.discrete',
74
'sympy.external',
75
'sympy.functions',
76
'sympy.functions.combinatorial',
77
'sympy.functions.elementary',
78
'sympy.functions.elementary.benchmarks',
79
'sympy.functions.special',
80
'sympy.functions.special.benchmarks',
81
'sympy.geometry',
82
'sympy.holonomic',
83
'sympy.integrals',
84
'sympy.integrals.benchmarks',
85
'sympy.interactive',
86
'sympy.liealgebras',
87
'sympy.logic',
88
'sympy.logic.algorithms',
89
'sympy.logic.utilities',
90
'sympy.matrices',
91
'sympy.matrices.benchmarks',
92
'sympy.matrices.expressions',
93
'sympy.multipledispatch',
94
'sympy.ntheory',
95
'sympy.parsing',
96
'sympy.parsing.autolev',
97
'sympy.parsing.autolev._antlr',
98
'sympy.parsing.c',
99
'sympy.parsing.fortran',
100
'sympy.parsing.latex',
101
'sympy.parsing.latex._antlr',
102
'sympy.parsing.latex.lark',
103
'sympy.physics',
104
'sympy.physics.biomechanics',
105
'sympy.physics.continuum_mechanics',
106
'sympy.physics.control',
107
'sympy.physics.hep',
108
'sympy.physics.mechanics',
109
'sympy.physics.optics',
110
'sympy.physics.quantum',
111
'sympy.physics.units',
112
'sympy.physics.units.definitions',
113
'sympy.physics.units.systems',
114
'sympy.physics.vector',
115
'sympy.plotting',
116
'sympy.plotting.backends',
117
'sympy.plotting.backends.matplotlibbackend',
118
'sympy.plotting.backends.textbackend',
119
'sympy.plotting.intervalmath',
120
'sympy.plotting.pygletplot',
121
'sympy.polys',
122
'sympy.polys.agca',
123
'sympy.polys.benchmarks',
124
'sympy.polys.domains',
125
'sympy.polys.matrices',
126
'sympy.polys.numberfields',
127
'sympy.polys.series',
128
'sympy.printing',
129
'sympy.printing.pretty',
130
'sympy.sandbox',
131
'sympy.series',
132
'sympy.series.benchmarks',
133
'sympy.sets',
134
'sympy.sets.handlers',
135
'sympy.simplify',
136
'sympy.solvers',
137
'sympy.solvers.benchmarks',
138
'sympy.solvers.diophantine',
139
'sympy.solvers.ode',
140
'sympy.stats',
141
'sympy.stats.sampling',
142
'sympy.strategies',
143
'sympy.strategies.branch',
144
'sympy.tensor',
145
'sympy.tensor.array',
146
'sympy.tensor.array.expressions',
147
'sympy.testing',
148
'sympy.unify',
149
'sympy.utilities',
150
'sympy.utilities._compilation',
151
'sympy.utilities.mathml',
152
'sympy.utilities.mathml.data',
153
'sympy.vector',
154
]
155
156
157
class test_sympy(Command):
158
"""Runs all tests under the sympy/ folder
159
"""
160
161
description = "run all tests and doctests; also see bin/test and bin/doctest"
162
user_options = [] # setuptools complains if this is not here.
163
164
def __init__(self, *args):
165
self.args = args[0] # so we can pass it to other classes
166
Command.__init__(self, *args)
167
168
def initialize_options(self): # setuptools wants this
169
pass
170
171
def finalize_options(self): # this too
172
pass
173
174
def run(self):
175
from sympy.testing import runtests
176
runtests.run_all_tests()
177
178
179
class antlr(Command):
180
"""Generate code with antlr4"""
181
description = "generate parser code from antlr grammars"
182
user_options = [] # setuptools complains if this is not here.
183
184
def __init__(self, *args):
185
self.args = args[0] # so we can pass it to other classes
186
Command.__init__(self, *args)
187
188
def initialize_options(self): # setuptools wants this
189
pass
190
191
def finalize_options(self): # this too
192
pass
193
194
def run(self):
195
from sympy.parsing.latex._build_latex_antlr import build_parser as build_latex_parser
196
if not build_latex_parser():
197
sys.exit(-1)
198
199
from sympy.parsing.autolev._build_autolev_antlr import build_parser as build_autolev_parser
200
if not build_autolev_parser():
201
sys.exit(-1)
202
203
204
class sdist_sympy(sdist):
205
def run(self):
206
# Fetch git commit hash and write down to commit_hash.txt before
207
# shipped in tarball.
208
commit_hash = None
209
commit_hash_filepath = 'doc/commit_hash.txt'
210
try:
211
commit_hash = \
212
subprocess.check_output(['git', 'rev-parse', 'HEAD'])
213
commit_hash = commit_hash.decode('ascii')
214
commit_hash = commit_hash.rstrip()
215
print('Commit hash found : {}.'.format(commit_hash))
216
print('Writing it to {}.'.format(commit_hash_filepath))
217
except Exception:
218
pass
219
220
if commit_hash:
221
Path(commit_hash_filepath).write_text(commit_hash)
222
223
super().run()
224
225
try:
226
os.remove(commit_hash_filepath)
227
print(
228
'Successfully removed temporary file {}.'
229
.format(commit_hash_filepath))
230
except OSError as e:
231
print("Error deleting %s - %s." % (e.filename, e.strerror))
232
233
234
# Check that this list is uptodate against the result of the command:
235
# python bin/generate_test_list.py
236
tests = [
237
'sympy.algebras.tests',
238
'sympy.assumptions.tests',
239
'sympy.calculus.tests',
240
'sympy.categories.tests',
241
'sympy.codegen.tests',
242
'sympy.combinatorics.tests',
243
'sympy.concrete.tests',
244
'sympy.core.tests',
245
'sympy.crypto.tests',
246
'sympy.diffgeom.tests',
247
'sympy.discrete.tests',
248
'sympy.external.tests',
249
'sympy.functions.combinatorial.tests',
250
'sympy.functions.elementary.tests',
251
'sympy.functions.special.tests',
252
'sympy.geometry.tests',
253
'sympy.holonomic.tests',
254
'sympy.integrals.tests',
255
'sympy.interactive.tests',
256
'sympy.liealgebras.tests',
257
'sympy.logic.tests',
258
'sympy.matrices.expressions.tests',
259
'sympy.matrices.tests',
260
'sympy.multipledispatch.tests',
261
'sympy.ntheory.tests',
262
'sympy.parsing.tests',
263
'sympy.physics.biomechanics.tests',
264
'sympy.physics.continuum_mechanics.tests',
265
'sympy.physics.control.tests',
266
'sympy.physics.hep.tests',
267
'sympy.physics.mechanics.tests',
268
'sympy.physics.optics.tests',
269
'sympy.physics.quantum.tests',
270
'sympy.physics.tests',
271
'sympy.physics.units.tests',
272
'sympy.physics.vector.tests',
273
'sympy.plotting.intervalmath.tests',
274
'sympy.plotting.pygletplot.tests',
275
'sympy.plotting.tests',
276
'sympy.polys.agca.tests',
277
'sympy.polys.domains.tests',
278
'sympy.polys.matrices.tests',
279
'sympy.polys.numberfields.tests',
280
'sympy.polys.series.tests',
281
'sympy.polys.tests',
282
'sympy.printing.pretty.tests',
283
'sympy.printing.tests',
284
'sympy.sandbox.tests',
285
'sympy.series.tests',
286
'sympy.sets.tests',
287
'sympy.simplify.tests',
288
'sympy.solvers.diophantine.tests',
289
'sympy.solvers.ode.tests',
290
'sympy.solvers.tests',
291
'sympy.stats.sampling.tests',
292
'sympy.stats.tests',
293
'sympy.strategies.branch.tests',
294
'sympy.strategies.tests',
295
'sympy.tensor.array.expressions.tests',
296
'sympy.tensor.array.tests',
297
'sympy.tensor.tests',
298
'sympy.testing.tests',
299
'sympy.unify.tests',
300
'sympy.utilities._compilation.tests',
301
'sympy.utilities.tests',
302
'sympy.vector.tests',
303
]
304
305
306
# Defines __version__
307
exec(Path(os.path.join(dir_setup, 'sympy', 'release.py')).read_text())
308
309
310
if __name__ == '__main__':
311
setup(name='sympy',
312
version=__version__, # noqa: F821
313
description='Computer algebra system (CAS) in Python',
314
long_description=(Path(__file__).parent / 'README.md').read_text("UTF-8"),
315
long_description_content_type='text/markdown',
316
author='SymPy development team',
317
author_email='[email protected]',
318
license='BSD',
319
keywords="Math CAS",
320
url='https://sympy.org',
321
project_urls={
322
'Source': 'https://github.com/sympy/sympy',
323
},
324
# Set upper bound when making the release branch.
325
install_requires=[
326
'mpmath >= 1.1.0',
327
],
328
py_modules=['isympy'],
329
packages=['sympy'] + modules + tests,
330
ext_modules=[],
331
package_data={
332
'sympy.utilities.mathml.data': ['*.xsl'],
333
'sympy.logic.benchmarks': ['input/*.cnf'],
334
'sympy.parsing.autolev': [
335
'*.g4', 'test-examples/*.al', 'test-examples/*.py',
336
'test-examples/pydy-example-repo/*.al',
337
'test-examples/pydy-example-repo/*.py',
338
'test-examples/README.txt',
339
],
340
'sympy.parsing.latex': ['*.txt', '*.g4', 'lark/grammar/*.lark'],
341
'sympy.plotting.tests': ['test_region_*.png'],
342
'sympy': ['py.typed']
343
},
344
data_files=[('share/man/man1', ['doc/man/isympy.1'])],
345
cmdclass={'test': test_sympy,
346
'antlr': antlr,
347
'sdist': sdist_sympy,
348
},
349
# Keep in sync with version check above and sympy/__init__.py
350
python_requires='>=3.9',
351
classifiers=[
352
'License :: OSI Approved :: BSD License',
353
'Operating System :: OS Independent',
354
'Programming Language :: Python',
355
'Topic :: Scientific/Engineering',
356
'Topic :: Scientific/Engineering :: Mathematics',
357
'Topic :: Scientific/Engineering :: Physics',
358
'Programming Language :: Python :: 3',
359
'Programming Language :: Python :: 3.9',
360
'Programming Language :: Python :: 3.10',
361
'Programming Language :: Python :: 3.11',
362
'Programming Language :: Python :: 3.12',
363
'Programming Language :: Python :: 3.13',
364
'Programming Language :: Python :: 3 :: Only',
365
'Programming Language :: Python :: Implementation :: CPython',
366
'Programming Language :: Python :: Implementation :: PyPy',
367
],
368
extras_require={
369
"dev": ["pytest>=7.1.0", "hypothesis>=6.70.0"],
370
},
371
**extra_kwargs
372
)
373
374