Added a warning when constructing a Matrix without bracket + test modified
[sympy.git] / setup.py
blob6f843d37b7e98a8a78efe4bb3775cf28d06b7887
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.galgebra', [] ),
55 ( True, 'sympy.geometry', [] ),
56 ( True, 'sympy.integrals', [] ),
57 ( True, 'sympy.interactive', [] ),
58 ( True, 'sympy.matrices', [] ),
59 ( True, 'sympy.ntheory', [] ),
60 ( False, 'sympy.parsing', [] ),
61 ( True, 'sympy.physics', [] ),
62 ( False, 'sympy.plotting', [] ),
63 ( False, 'sympy.thirdparty', [] ),
64 ( False, 'sympy.mpmath', [] ),
65 ( True, 'sympy.polynomials', [] ),
66 ( True, 'sympy.polynomials.fast', [] ),
67 ( True, 'sympy.polys', ['wrappers'] ),
68 ( True, 'sympy.printing', ['gtk', 'tree'] ),
69 ( True, 'sympy.printing.pretty', [] ),
70 ( True, 'sympy.series', ["limits"] ),
71 ( True, 'sympy.simplify', [] ),
72 ( True, 'sympy.solvers', [] ),
73 ( True, 'sympy.statistics', [] ),
74 ( True, 'sympy.utilities', ["compilef"] ),
75 ( True, 'sympy.utilities.mathml', [] ),
78 class clean(Command):
79 """Cleans *.pyc and debian trashs, so you should get the same copy as
80 is in the svn.
81 """
83 description = "Clean everything"
84 user_options = [("all","a","the same")]
86 def initialize_options(self):
87 self.all = None
89 def finalize_options(self):
90 pass
92 def run(self):
93 import os
94 os.system("py.cleanup")
95 os.system("rm -f python-build-stamp-2.4")
96 os.system("rm -f MANIFEST")
97 os.system("rm -rf build")
98 os.system("rm -rf dist")
100 class gen_doc(Command):
101 """Generate the (html) api documentation using epydoc
103 output is sent to the directory ../api/
106 description = "generate the api doc"
107 user_options = []
109 target_dir = "../api/"
111 def initialize_options(self):
112 self.all = None
114 def finalize_options(self):
115 pass
117 def run(self):
118 import os
119 os.system("epydoc --no-frames -o %s sympy" % self.target_dir)
122 class test_sympy_core(Command):
123 """Run only the tests concerning features of sympy.core.
124 It's a lot faster than running the complete test suite.
127 description = "Automatically run the core test suite for Sympy."
128 user_options = [] # distutils complains if this is not here.
130 def initialize_options(self): # distutils wants this
131 pass
133 def finalize_options(self): # this too
134 pass
137 def run(self):
138 try:
139 import py
140 except ImportError:
141 print """In order to run the tests, you need codespeak's py.lib
142 web page: http://codespeak.net/py/dist/
143 If you are on debian systems, the package is named python-codespeak-lib
145 sys.exit(-1)
146 py.test.cmdline.main(args=["sympy/core/tests"])
149 class test_sympy(Command):
150 """Runs all tests under the sympy/ folder
153 description = "Automatically run the test suite for Sympy."
154 user_options = [] # distutils complains if this is not here.
156 def __init__(self, *args):
157 self.args = args[0] # so we can pass it to other classes
158 Command.__init__(self, *args)
160 def initialize_options(self): # distutils wants this
161 pass
163 def finalize_options(self): # this too
164 pass
166 def run(self):
167 try:
168 import py as pylib
169 except ImportError:
170 print """In order to run the tests, you need codespeak's py.lib
171 web page: http://codespeak.net/py/dist/
172 If you are on debian systems, the package is named python-codespeak-lib
174 sys.exit(-1)
175 pylib.test.cmdline.main(args=["sympy"])
176 tdoc = test_sympy_doc(self.args)
177 tdoc.run() # run also the doc test suite
179 class test_sympy_doc(Command):
181 description = "Run the tests for the examples in the documentation"
182 user_options = [] # distutils complains if this is not here.
184 def initialize_options(self): # distutils wants this
185 pass
187 def finalize_options(self): # this too
188 pass
190 def run(self):
191 import unittest
192 import doctest
194 import glob
196 print "Testing docstrings."
198 def setup_pprint():
199 from sympy import pprint_use_unicode
200 # force pprint to be in ascii mode in doctests
201 pprint_use_unicode(False)
203 # hook our nice, hash-stable strprinter
204 from sympy.interactive import init_printing
205 from sympy.printing import sstrrepr
206 init_printing(sstrrepr)
208 suite = unittest.TestSuite()
210 for perform, module, specific in modules:
211 if perform == True:
212 path = module.replace('.', '/')
214 items = glob.glob(path + '/[a-z][a-z0-9_]*.py')
215 items = [ i.replace('\\', '/') for i in items ]
217 for omit in specific:
218 items.remove(path + '/' + omit + '.py')
220 for item in items:
221 module = item.replace('/', '.')[:-3]
222 suite.addTest(doctest.DocTestSuite(module))
224 setup_pprint()
226 runner = unittest.TextTestRunner()
227 runner.run(suite)
230 class run_benchmarks(Command):
231 """Runs all SymPy benchmarks"""
233 description = "Automatically run the test suite for Sympy."
234 user_options = [] # distutils complains if this is not here.
236 def __init__(self, *args):
237 self.args = args[0] # so we can pass it to other classes
238 Command.__init__(self, *args)
240 def initialize_options(self): # distutils wants this
241 pass
243 def finalize_options(self): # this too
244 pass
246 # we use py.test like architecture:
248 # o collector -- collects benchmarks
249 # o runner -- executes benchmarks
250 # o presenter -- displays benchmarks results
252 # this is done in sympy.utilities.benchmarking on top of py.test
253 def run(self):
254 from sympy.utilities import benchmarking
255 benchmarking.main(['sympy'])
258 # Check that this list is uptodate against the result of the command:
259 # $ python bin/generate_test_list.py
260 tests = [
261 'sympy.concrete.tests',
262 'sympy.core.tests',
263 'sympy.functions.combinatorial.tests',
264 'sympy.functions.elementary.tests',
265 'sympy.functions.special.tests',
266 'sympy.geometry.tests',
267 'sympy.integrals.tests',
268 'sympy.matrices.tests',
269 'sympy.mpmath.tests',
270 'sympy.ntheory.tests',
271 'sympy.parsing.tests',
272 'sympy.physics.tests',
273 'sympy.plotting.tests',
274 'sympy.polynomials.tests',
275 'sympy.polys.tests',
276 'sympy.printing.pretty.tests',
277 'sympy.printing.tests',
278 'sympy.series.tests',
279 'sympy.simplify.tests',
280 'sympy.solvers.tests',
281 'sympy.statistics.tests',
282 'sympy.test_external',
283 'sympy.utilities.tests',
286 # update the following list from:
287 # http://pyglet.googlecode.com/svn/trunk/setup.py
288 # (whenever we update pyglet in sympy)
289 pyglet_packages=[
290 'pyglet',
291 'pyglet.gl',
292 'pyglet.font',
293 'pyglet.image',
294 'pyglet.image.codecs',
295 'pyglet.media',
296 'pyglet.media.drivers',
297 'pyglet.media.drivers.alsa',
298 'pyglet.media.drivers.directsound',
299 'pyglet.media.drivers.openal',
300 'pyglet.window',
301 'pyglet.window.carbon',
302 'pyglet.window.win32',
303 'pyglet.window.xlib',
305 pyglet_packages = ["sympy.thirdparty.pyglet." + s for s in pyglet_packages]
307 setup(
308 name = 'sympy',
309 version = sympy.__version__,
310 description = 'Computer algebra system (CAS) in Python',
311 license = 'BSD',
312 url = 'http://code.google.com/p/sympy',
313 packages = ['sympy'] + [ m[1] for m in modules ] + tests + \
314 pyglet_packages,
315 scripts = ['bin/isympy', 'bin/py.bench'],
316 ext_modules = [],
317 package_data = { 'sympy.utilities.mathml' : ['data/*.xsl'] },
318 data_files = [('share/man/man1', ['doc/man/isympy.1'])],
319 cmdclass = {'test': test_sympy,
320 'test_core' : test_sympy_core,
321 'test_doc' : test_sympy_doc,
322 'bench' : run_benchmarks,
323 'gen_doc' : gen_doc,
324 'clean' : clean,