A test for the issue #469 written.
[sympy.git] / setup.py
blobb5ae0a55efef5218c181dccdac5cc6564b548845
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
22 To get a full list of avaiable commands, read the output of:
24 python setup.py --help-commands
26 Or, if all else fails, feel free to write to the sympy list at
27 sympy@googlegroups.com and ask for help.
28 """
30 from distutils.core import setup
31 from distutils.core import Command
32 import sys
34 import sympy
36 # Make sure I have the right Python version.
37 if sys.version_info[1] < 4:
38 print "Sympy requires Python 2.4 or newer. Python %d.%d detected" % \
39 sys.version_info[:2]
40 sys.exit(-1)
42 #Check that this list is uptodate against the result of the command:
43 #$ find * -name __init__.py |sort
44 modules = [
45 # do docstring # module name # omit those even if the first field is True
46 ( True, 'sympy.concrete', [] ),
47 ( True, 'sympy.core', ['add', 'mul', 'relational', 'interval'] ),
48 ( True, 'sympy.functions', [] ),
49 ( True, 'sympy.functions.combinatorial', [] ),
50 ( True, 'sympy.functions.elementary',
51 ['miscellaneous', 'trigonometric', 'hyperbolic', 'exponential'] ),
52 ( False, 'sympy.functions.special', [] ),
53 ( True, 'sympy.geometry', [] ),
54 ( True, 'sympy.integrals', [] ),
55 ( True, 'sympy.matrices', [] ),
56 ( True, 'sympy.ntheory', [] ),
57 ( True, 'sympy.numerics', [] ),
58 ( False, 'sympy.parsing', [] ),
59 ( True, 'sympy.physics', [] ),
60 ( False, 'sympy.plotting', [] ),
61 ( False, 'sympy.plotting.pyglet', [] ),
62 ( False, 'sympy.plotting.pyglet.font', [] ),
63 ( False, 'sympy.plotting.pyglet.gl', [] ),
64 ( False, 'sympy.plotting.pyglet.image', [] ),
65 ( False, 'sympy.plotting.pyglet.image.codecs', [] ),
66 ( False, 'sympy.plotting.pyglet.media', [] ),
67 ( False, 'sympy.plotting.pyglet.media.drivers', [] ),
68 ( False, 'sympy.plotting.pyglet.media.drivers.alsa', [] ),
69 ( False, 'sympy.plotting.pyglet.media.drivers.directsound', [] ),
70 ( False, 'sympy.plotting.pyglet.media.drivers.openal', [] ),
71 ( False, 'sympy.plotting.pyglet.window', [] ),
72 ( False, 'sympy.plotting.pyglet.window.carbon', [] ),
73 ( False, 'sympy.plotting.pyglet.window.win32', [] ),
74 ( False, 'sympy.plotting.pyglet.window.xlib', [] ),
75 ( True, 'sympy.polynomials', [] ),
76 ( True, 'sympy.polynomials.fast', [] ),
77 ( True, 'sympy.printing', ['gtk'] ),
78 ( True, 'sympy.printing.pretty', [] ),
79 ( True, 'sympy.series', ["limits"] ),
80 ( True, 'sympy.simplify', [] ),
81 ( True, 'sympy.solvers', [] ),
82 ( True, 'sympy.specfun', [] ),
83 ( True, 'sympy.statistics', [] ),
84 ( True, 'sympy.utilities', [] ),
85 ( True, 'sympy.utilities.mathml', [] ),
88 class clean(Command):
89 """Cleans *.pyc and debian trashs, so you should get the same copy as
90 is in the svn.
91 """
93 description = "Clean everything"
94 user_options = [("all","a","the same")]
96 def initialize_options(self):
97 self.all = None
99 def finalize_options(self):
100 pass
102 def run(self):
103 import os
104 os.system("py.cleanup")
105 os.system("rm -f python-build-stamp-2.4")
106 os.system("rm -f MANIFEST")
107 os.system("rm -rf build")
108 os.system("rm -rf dist")
110 class gen_doc(Command):
111 """Generate the (html) api documentation using epydoc
113 output is sent to the directory ../api/
116 description = "generate the api doc"
117 user_options = []
119 target_dir = "../api/"
121 def initialize_options(self):
122 self.all = None
124 def finalize_options(self):
125 pass
127 def run(self):
128 import os
129 os.system("epydoc --no-frames -o %s sympy" % self.target_dir)
132 class test_sympy_core(Command):
133 """Run only the tests concerning features of sympy.core.
134 It's a lot faster than running the complete test suite.
137 description = "Automatically run the core test suite for Sympy."
138 user_options = [] # distutils complains if this is not here.
140 def initialize_options(self): # distutils wants this
141 pass
143 def finalize_options(self): # this too
144 pass
147 def run(self):
148 try:
149 import py
150 except ImportError:
151 print """In order to run the tests, you need codespeak's py.lib
152 web page: http://codespeak.net/py/dist/
153 If you are on debian systems, the package is named python-codespeak-lib
155 sys.exit(-1)
156 py.test.cmdline.main(args=["sympy/core/tests"])
159 class test_sympy(Command):
160 """Runs all tests under the sympy/ folder
163 description = "Automatically run the test suite for Sympy."
164 user_options = [] # distutils complains if this is not here.
166 def __init__(self, *args):
167 self.args = args[0] # so we can pass it to other classes
168 Command.__init__(self, *args)
170 def initialize_options(self): # distutils wants this
171 pass
173 def finalize_options(self): # this too
174 pass
176 def run(self):
177 try:
178 import py as pylib
179 except ImportError:
180 print """In order to run the tests, you need codespeak's py.lib
181 web page: http://codespeak.net/py/dist/
182 If you are on debian systems, the package is named python-codespeak-lib
184 sys.exit(-1)
185 pylib.test.cmdline.main(args=["sympy"])
186 tdoc = test_sympy_doc(self.args)
187 tdoc.run() # run also the doc test suite
189 class test_sympy_doc(Command):
191 description = "Run the tests for the examples in the documentation"
192 user_options = [] # distutils complains if this is not here.
194 def initialize_options(self): # distutils wants this
195 pass
197 def finalize_options(self): # this too
198 pass
200 def run(self):
201 import unittest
202 import doctest
204 import glob
206 print "Testing docstrings."
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 runner = unittest.TextTestRunner()
225 runner.run(suite)
227 #Check that this list is uptodate against the result of the command:
228 #$ find * -name tests |sort
229 tests = [
230 'sympy.concrete.tests',
231 'sympy.core.tests',
232 'sympy.functions.combinatorial.tests',
233 'sympy.functions.elementary.tests',
234 'sympy.functions.special.tests',
235 'sympy.geometry.tests',
236 'sympy.integrals.tests',
237 'sympy.matrices.tests',
238 'sympy.ntheory.tests',
239 'sympy.numerics.tests',
240 'sympy.parsing.tests',
241 'sympy.physics.tests',
242 'sympy.plotting.tests',
243 'sympy.polynomials.tests',
244 'sympy.printing.tests',
245 'sympy.series.tests',
246 'sympy.simplify.tests',
247 'sympy.solvers.tests',
248 'sympy.specfun.tests',
249 'sympy.statistics.tests',
250 'sympy.utilities.tests',
253 setup(
254 name = 'sympy',
255 version = sympy.__version__,
256 description = 'Computer algebra system (CAS) in Python',
257 license = 'BSD',
258 url = 'http://code.google.com/p/sympy',
259 packages = ['sympy'] + [ m[1] for m in modules ] + tests,
260 scripts = ['bin/isympy'],
261 ext_modules = [],
262 package_data = { 'sympy.utilities.mathml' : ['data/*.xsl'] },
263 data_files = [('share/man/man1', ['doc/man/isympy.1'])],
264 cmdclass = {'test': test_sympy,
265 'test_core' : test_sympy_core,
266 'test_doc' : test_sympy_doc,
267 'gen_doc' : gen_doc,
268 'clean' : clean,