./setup.py bench now works correctly!
[sympy.git] / setup.py
blob94e1643f34784af4999f9b4104e86c879b085a43
1 #!/usr/bin/env python
2 """Distutils based setup script for Sympy.
4 This uses Distutils (http://python.org/sigs/distutils-sig/) the standard
5 python mechanism for installing packages. For the easiest installation
6 just type the command (you'll probably need root privileges for that):
8 python setup.py install
10 This will install the library in the default location. For instructions on
11 how to customize the install procedure read the output of:
13 python setup.py --help install
15 In addition, there are some other commands:
17 python setup.py clean -> will clean all trash (*.pyc and stuff)
18 python setup.py test -> will run the complete test suite
19 python setup.py test_core -> will run only tests concerning core features
20 python setup.py test_doc -> will run tests on the examples of the documentation
21 python setup.py bench -> will run the complete benchmark suite
23 To get a full list of avaiable commands, read the output of:
25 python setup.py --help-commands
27 Or, if all else fails, feel free to write to the sympy list at
28 sympy@googlegroups.com and ask for help.
29 """
31 from distutils.core import setup
32 from distutils.core import Command
33 import sys
35 import sympy
37 # Make sure I have the right Python version.
38 if sys.version_info[1] < 4:
39 print "Sympy requires Python 2.4 or newer. Python %d.%d detected" % \
40 sys.version_info[:2]
41 sys.exit(-1)
43 #Check that this list is uptodate against the result of the command:
44 #$ find * -name __init__.py |sort
45 modules = [
46 # do docstring # module name # omit those even if the first field is True
47 ( True, 'sympy.concrete', [] ),
48 ( True, 'sympy.core', ['add', 'mul', 'relational', 'interval', 'ast_parser'] ),
49 ( True, 'sympy.functions', [] ),
50 ( True, 'sympy.functions.combinatorial', [] ),
51 ( True, 'sympy.functions.elementary',
52 ['miscellaneous', 'trigonometric', 'hyperbolic', 'exponential'] ),
53 ( False, 'sympy.functions.special', [] ),
54 ( True, 'sympy.geometry', [] ),
55 ( True, 'sympy.integrals', [] ),
56 ( True, 'sympy.interactive', [] ),
57 ( True, 'sympy.matrices', [] ),
58 ( True, 'sympy.ntheory', [] ),
59 ( False, 'sympy.parsing', [] ),
60 ( True, 'sympy.physics', [] ),
61 ( False, 'sympy.plotting', [] ),
62 ( False, 'sympy.thirdparty', [] ),
63 ( False, 'sympy.mpmath', [] ),
64 ( True, 'sympy.polynomials', [] ),
65 ( True, 'sympy.polynomials.fast', [] ),
66 ( True, 'sympy.polys', ['wrappers'] ),
67 ( True, 'sympy.printing', ['gtk', 'tree'] ),
68 ( True, 'sympy.printing.pretty', [] ),
69 ( True, 'sympy.series', ["limits"] ),
70 ( True, 'sympy.simplify', [] ),
71 ( True, 'sympy.solvers', [] ),
72 ( True, 'sympy.statistics', [] ),
73 ( True, 'sympy.utilities', ["compilef"] ),
74 ( True, 'sympy.utilities.mathml', [] ),
77 class clean(Command):
78 """Cleans *.pyc and debian trashs, so you should get the same copy as
79 is in the svn.
80 """
82 description = "Clean everything"
83 user_options = [("all","a","the same")]
85 def initialize_options(self):
86 self.all = None
88 def finalize_options(self):
89 pass
91 def run(self):
92 import os
93 os.system("py.cleanup")
94 os.system("rm -f python-build-stamp-2.4")
95 os.system("rm -f MANIFEST")
96 os.system("rm -rf build")
97 os.system("rm -rf dist")
99 class gen_doc(Command):
100 """Generate the (html) api documentation using epydoc
102 output is sent to the directory ../api/
105 description = "generate the api doc"
106 user_options = []
108 target_dir = "../api/"
110 def initialize_options(self):
111 self.all = None
113 def finalize_options(self):
114 pass
116 def run(self):
117 import os
118 os.system("epydoc --no-frames -o %s sympy" % self.target_dir)
121 class test_sympy_core(Command):
122 """Run only the tests concerning features of sympy.core.
123 It's a lot faster than running the complete test suite.
126 description = "Automatically run the core test suite for Sympy."
127 user_options = [] # distutils complains if this is not here.
129 def initialize_options(self): # distutils wants this
130 pass
132 def finalize_options(self): # this too
133 pass
136 def run(self):
137 try:
138 import py
139 except ImportError:
140 print """In order to run the tests, you need codespeak's py.lib
141 web page: http://codespeak.net/py/dist/
142 If you are on debian systems, the package is named python-codespeak-lib
144 sys.exit(-1)
145 py.test.cmdline.main(args=["sympy/core/tests"])
148 class test_sympy(Command):
149 """Runs all tests under the sympy/ folder
152 description = "Automatically run the test suite for Sympy."
153 user_options = [] # distutils complains if this is not here.
155 def __init__(self, *args):
156 self.args = args[0] # so we can pass it to other classes
157 Command.__init__(self, *args)
159 def initialize_options(self): # distutils wants this
160 pass
162 def finalize_options(self): # this too
163 pass
165 def run(self):
166 try:
167 import py as pylib
168 except ImportError:
169 print """In order to run the tests, you need codespeak's py.lib
170 web page: http://codespeak.net/py/dist/
171 If you are on debian systems, the package is named python-codespeak-lib
173 sys.exit(-1)
174 pylib.test.cmdline.main(args=["sympy"])
175 tdoc = test_sympy_doc(self.args)
176 tdoc.run() # run also the doc test suite
178 class test_sympy_doc(Command):
180 description = "Run the tests for the examples in the documentation"
181 user_options = [] # distutils complains if this is not here.
183 def initialize_options(self): # distutils wants this
184 pass
186 def finalize_options(self): # this too
187 pass
189 def run(self):
190 import unittest
191 import doctest
193 import glob
195 print "Testing docstrings."
197 def setup_pprint():
198 from sympy import pprint_use_unicode
199 # force pprint to be in ascii mode in doctests
200 pprint_use_unicode(False)
202 # hook our nice, hash-stable strprinter
203 from sympy.interactive import init_printing
204 from sympy.printing import sstrrepr
205 init_printing(sstrrepr)
207 suite = unittest.TestSuite()
209 for perform, module, specific in modules:
210 if perform == True:
211 path = module.replace('.', '/')
213 items = glob.glob(path + '/[a-z][a-z0-9_]*.py')
214 items = [ i.replace('\\', '/') for i in items ]
216 for omit in specific:
217 items.remove(path + '/' + omit + '.py')
219 for item in items:
220 module = item.replace('/', '.')[:-3]
221 suite.addTest(doctest.DocTestSuite(module))
223 setup_pprint()
225 runner = unittest.TextTestRunner()
226 runner.run(suite)
229 class run_benchmarks(Command):
230 """Runs all SymPy benchmarks"""
232 description = "Automatically run the test suite for Sympy."
233 user_options = [] # distutils complains if this is not here.
235 def __init__(self, *args):
236 self.args = args[0] # so we can pass it to other classes
237 Command.__init__(self, *args)
239 def initialize_options(self): # distutils wants this
240 pass
242 def finalize_options(self): # this too
243 pass
245 # we use py.test like architecture:
247 # o collector -- collects benchmarks
248 # o runner -- executes benchmarks
249 # o presenter -- displays benchmarks results
251 # this is done in sympy.utilities.benchmarking on top of py.test
252 def run(self):
253 from sympy.utilities import benchmarking
254 benchmarking.main(['sympy'])
257 # Check that this list is uptodate against the result of the command:
258 # $ python bin/generate_test_list.py
259 tests = [
260 'sympy.concrete.tests',
261 'sympy.core.tests',
262 'sympy.functions.combinatorial.tests',
263 'sympy.functions.elementary.tests',
264 'sympy.functions.special.tests',
265 'sympy.geometry.tests',
266 'sympy.integrals.tests',
267 'sympy.matrices.tests',
268 'sympy.mpmath.tests',
269 'sympy.ntheory.tests',
270 'sympy.parsing.tests',
271 'sympy.physics.tests',
272 'sympy.plotting.tests',
273 'sympy.polynomials.tests',
274 'sympy.polys.tests',
275 'sympy.printing.pretty.tests',
276 'sympy.printing.tests',
277 'sympy.series.tests',
278 'sympy.simplify.tests',
279 'sympy.solvers.tests',
280 'sympy.statistics.tests',
281 'sympy.test_external',
282 'sympy.utilities.tests',
285 # update the following list from:
286 # http://pyglet.googlecode.com/svn/trunk/setup.py
287 # (whenever we update pyglet in sympy)
288 pyglet_packages=[
289 'pyglet',
290 'pyglet.gl',
291 'pyglet.font',
292 'pyglet.image',
293 'pyglet.image.codecs',
294 'pyglet.media',
295 'pyglet.media.drivers',
296 'pyglet.media.drivers.alsa',
297 'pyglet.media.drivers.directsound',
298 'pyglet.media.drivers.openal',
299 'pyglet.window',
300 'pyglet.window.carbon',
301 'pyglet.window.win32',
302 'pyglet.window.xlib',
304 pyglet_packages = ["sympy.thirdparty.pyglet." + s for s in pyglet_packages]
306 setup(
307 name = 'sympy',
308 version = sympy.__version__,
309 description = 'Computer algebra system (CAS) in Python',
310 license = 'BSD',
311 url = 'http://code.google.com/p/sympy',
312 packages = ['sympy'] + [ m[1] for m in modules ] + tests + \
313 pyglet_packages,
314 scripts = ['bin/isympy', 'bin/py.bench'],
315 ext_modules = [],
316 package_data = { 'sympy.utilities.mathml' : ['data/*.xsl'] },
317 data_files = [('share/man/man1', ['doc/man/isympy.1'])],
318 cmdclass = {'test': test_sympy,
319 'test_core' : test_sympy_core,
320 'test_doc' : test_sympy_doc,
321 'bench' : run_benchmarks,
322 'gen_doc' : gen_doc,
323 'clean' : clean,