forked from mathics/Mathics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
224 lines (178 loc) · 7.02 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import absolute_import
"""Setuptools based setup script for Mathics.
For the easiest installation just type the following command (you'll probably
need root privileges):
python setup.py install
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
Or, if all else fails, feel free to write to the mathics users list at
mathics-users@googlegroups.com and ask for help.
"""
import sys
import platform
import os
from setuptools import setup, Command, Extension
# Ensure user has the correct Python version
if sys.version_info[:2] != (2, 7) and sys.version_info < (3, 2):
print("Mathics does not support Python %d.%d" % sys.version_info[:2])
sys.exit(-1)
# stores __version__ in the current namespace
exec(compile(open('mathics/version.py').read(), 'mathics/version.py', 'exec'))
is_PyPy = (platform.python_implementation() == 'PyPy')
INSTALL_REQUIRES = []
DEPENDENCY_LINKS = []
try:
if is_PyPy:
raise ImportError
from Cython.Distutils import build_ext
except ImportError:
EXTENSIONS = []
CMDCLASS = {}
else:
EXTENSIONS = {
'core': ['expression', 'numbers', 'rules', 'pattern'],
'builtin': ['arithmetic', 'numeric', 'patterns', 'graphics']
}
EXTENSIONS = [
Extension('mathics.%s.%s' % (parent, module),
['mathics/%s/%s.py' % (parent, module)])
for parent, modules in EXTENSIONS.items() for module in modules]
CMDCLASS = {'build_ext': build_ext}
INSTALL_REQUIRES += ['cython>=0.15.1']
# General Requirements
INSTALL_REQUIRES += ['sympy==1.0', 'django >= 1.8, < 1.9a0',
'mpmath>=0.19', 'python-dateutil', 'colorama', 'six>=1.10']
def subdirs(root, file='*.*', depth=10):
for k in range(depth):
yield root + '*/' * k + file
class initialize(Command):
"""
Manually create the Django database used by the web notebook
"""
description = "manually create the Django database used by the web notebook"
user_options = [] # distutils complains if this is not here.
def __init__(self, *args):
self.args = args[0] # so we can pass it to other classes
Command.__init__(self, *args)
def initialize_options(self): # distutils wants this
pass
def finalize_options(self): # this too
pass
def run(self):
import os
import subprocess
settings = {}
exec(compile(open('mathics/settings.py').read(), 'mathics/settings.py', 'exec'), settings)
database_file = settings['DATABASES']['default']['NAME']
print("Creating data directory %s" % settings['DATA_DIR'])
if not os.path.exists(settings['DATA_DIR']):
os.makedirs(settings['DATA_DIR'])
print("Creating database %s" % database_file)
try:
subprocess.check_call(
[sys.executable, 'mathics/manage.py', 'migrate', '--noinput'])
print("")
print("Database created successfully.")
except subprocess.CalledProcessError:
print("Error: failed to create database")
sys.exit(1)
class test(Command):
"""
Run the unittests
"""
description = "run the unittests"
user_options = []
def __init__(self, *args):
self.args = args[0] # so we can pass it to other classes
Command.__init__(self, *args)
def initialize_options(self): # distutils wants this
pass
def finalize_options(self): # this too
pass
def run(self):
import unittest
test_loader = unittest.defaultTestLoader
test_runner = unittest.TextTestRunner(verbosity=3)
test_suite = test_loader.discover('test/')
test_result = test_runner.run(test_suite)
if not test_result.wasSuccessful():
sys.exit(1)
CMDCLASS['initialize'] = initialize
CMDCLASS['test'] = test
mathjax_files = list(subdirs('media/js/mathjax/'))
setup(
name="Mathics",
cmdclass=CMDCLASS,
ext_modules=EXTENSIONS,
version=__version__,
packages=[
'mathics',
'mathics.algorithm',
'mathics.core',
'mathics.core.parser',
'mathics.builtin', 'mathics.builtin.pymimesniffer', 'mathics.builtin.numpy_utils',
'mathics.builtin.pympler', 'mathics.builtin.compile',
'mathics.doc',
'mathics.web', 'mathics.web.templatetags'
],
install_requires=INSTALL_REQUIRES,
dependency_links=DEPENDENCY_LINKS,
package_data={
'mathics': [
'data/*.csv', 'data/ExampleData/*',
'autoload/formats/*/Import.m', 'autoload/formats/*/Export.m',
'packages/*/*.m', 'packages/*/Kernel/init.m'],
'mathics.doc': ['documentation/*.mdoc', 'xml/data'],
'mathics.web': [
'media/css/*.css', 'media/img/*.*', 'media/fonts/*',
'media/img/favicons/*',
'media/js/innerdom/*.js', 'media/js/prototype/*.js',
'media/js/scriptaculous/*.js', 'media/js/three/Three.js',
'media/js/three/Detector.js', 'media/js/*.js', 'templates/*.html',
'templates/doc/*.html'] + mathjax_files,
'mathics.builtin.pymimesniffer': ['mimetypes.xml'],
},
entry_points={
'console_scripts': [
'mathics = mathics.main:main',
'mathicsserver = mathics.server:main',
'mathicsscript = mathics.script:main',
],
},
# don't pack Mathics in egg because of media files, etc.
zip_safe=False,
# metadata for upload to PyPI
author="Angus Griffith",
author_email="mathics@angusgriffith.com",
description="A general-purpose computer algebra system.",
license="GPL",
url="https://mathics.github.io/",
download_url="https://github.com/mathics/Mathics/tarball/v0.9",
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 :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'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,
)