fixed the doctest bug
[sympy.git] / setup.py
blobed6cacc8de1b9d10148e4802a572267a444c60e1
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 modules = [
43 # do docstring # module name # omit those even if the first field is True
44 ( True, 'sympy.core',
45 ['add', 'mul', 'relational', 'interval'] ),
46 ( True, 'sympy.concrete', [] ),
47 ( True, 'sympy.functions', [] ),
48 ( True, 'sympy.functions.combinatorial', [] ),
49 ( True, 'sympy.functions.elementary',
50 ['miscellaneous', 'trigonometric', 'hyperbolic', 'exponential'] ),
51 ( False, 'sympy.functions.special', [] ),
52 ( True, 'sympy.geometry', [] ),
53 ( True, 'sympy.integrals', [] ),
54 ( True, 'sympy.matrices', [] ),
55 ( True, 'sympy.ntheory', [] ),
56 ( True, 'sympy.numerics', [] ),
57 ( True, 'sympy.physics', [] ),
58 ( True, 'sympy.polynomials', [] ),
59 ( True, 'sympy.polynomials.fast', [] ),
60 ( True, 'sympy.printing',
61 ['gtk', 'pygame_'] ),
62 ( True, 'sympy.series', ["limits_oldcore", "limits"] ),
63 ( True, 'sympy.simplify', [] ),
64 ( True, 'sympy.solvers', [] ),
65 ( True, 'sympy.utilities', [] ),
66 ( False, 'sympy.plotting', [] ),
67 ( False, 'sympy.plotting.pyglet', [] ),
68 ( False, 'sympy.plotting.pyglet.ext', [] ),
69 ( False, 'sympy.plotting.pyglet.font', [] ),
70 ( False, 'sympy.plotting.pyglet.gl', [] ),
71 ( False, 'sympy.plotting.pyglet.image', [] ),
72 ( False, 'sympy.plotting.pyglet.image.codecs', [] ),
73 ( False, 'sympy.plotting.pyglet.media', [] ),
74 ( False, 'sympy.plotting.pyglet.window', [] ),
75 ( False, 'sympy.plotting.pyglet.window.carbon', [] ),
76 ( False, 'sympy.plotting.pyglet.window.win32', [] ),
77 ( False, 'sympy.plotting.pyglet.window.xlib', [] ),
80 class clean(Command):
81 """Cleans *.pyc and debian trashs, so you should get the same copy as
82 is in the svn.
83 """
85 description = "Clean everything"
86 user_options = [("all","a","the same")]
88 def initialize_options(self):
89 self.all = None
91 def finalize_options(self):
92 pass
94 def run(self):
95 import os
96 os.system("py.cleanup")
97 os.system("rm -f python-build-stamp-2.4")
98 os.system("rm -f MANIFEST")
99 os.system("rm -rf build")
100 os.system("rm -rf dist")
102 class gen_doc(Command):
103 """Generate the (html) api documentation using epydoc
105 output is sent to the directory ../api/
108 description = "generate the api doc"
109 user_options = []
111 target_dir = "../api/"
113 def initialize_options(self):
114 self.all = None
116 def finalize_options(self):
117 pass
119 def run(self):
120 import os
121 os.system("epydoc --no-frames -o %s sympy" % self.target_dir)
124 class test_sympy_core(Command):
125 """Run only the tests concerning features of sympy.core.
126 It's a lot faster than running the complete test suite.
129 description = "Automatically run the core test suite for Sympy."
130 user_options = [] # distutils complains if this is not here.
132 def initialize_options(self): # distutils wants this
133 pass
135 def finalize_options(self): # this too
136 pass
139 def run(self):
140 try:
141 import py
142 except ImportError:
143 print """In order to run the tests, you need codespeak's py.lib
144 web page: http://codespeak.net/py/dist/
145 If you are on debian systems, the package is named python-codespeak-lib
147 sys.exit(-1)
148 py.test.cmdline.main(args=["sympy/core/tests"])
151 class test_sympy(Command):
152 """Runs all tests under the sympy/ folder
155 description = "Automatically run the test suite for Sympy."
156 user_options = [] # distutils complains if this is not here.
158 def __init__(self, *args):
159 self.args = args[0] # so we can pass it to other classes
160 Command.__init__(self, *args)
162 def initialize_options(self): # distutils wants this
163 pass
165 def finalize_options(self): # this too
166 pass
168 def run(self):
169 try:
170 import py as pylib
171 except ImportError:
172 print """In order to run the tests, you need codespeak's py.lib
173 web page: http://codespeak.net/py/dist/
174 If you are on debian systems, the package is named python-codespeak-lib
176 sys.exit(-1)
177 pylib.test.cmdline.main(args=["sympy"])
178 tdoc = test_sympy_doc(self.args)
179 tdoc.run() # run also the doc test suite
181 class test_sympy_doc(Command):
183 description = "Run the tests for the examples in the documentation"
184 user_options = [] # distutils complains if this is not here.
186 def initialize_options(self): # distutils wants this
187 pass
189 def finalize_options(self): # this too
190 pass
192 def run(self):
193 import unittest
194 import doctest
196 import glob
198 print "Testing docstrings."
200 suite = unittest.TestSuite()
202 for perform, module, specific in modules:
203 if perform == True:
204 path = module.replace('.', '/')
206 items = glob.glob(path + '/[a-z][a-z0-9_]*.py')
207 items = [ i.replace('\\', '/') for i in items ]
209 for omit in specific:
210 items.remove(path + '/' + omit + '.py')
212 for item in items:
213 module = item.replace('/', '.')[:-3]
214 suite.addTest(doctest.DocTestSuite(module))
216 runner = unittest.TextTestRunner()
217 runner.run(suite)
219 tests = [
220 'sympy.core.tests',
221 'sympy.concrete.tests',
222 'sympy.functions.combinatorial.tests',
223 'sympy.functions.elementary.tests',
224 'sympy.functions.special.tests',
225 'sympy.geometry.tests',
226 'sympy.integrals.tests',
227 'sympy.matrices.tests',
228 'sympy.numerics.tests',
229 'sympy.ntheory.tests',
230 'sympy.physics.tests',
231 'sympy.polynomials.tests',
232 'sympy.printing.tests',
233 'sympy.series.tests',
234 'sympy.simplify.tests',
235 'sympy.solvers.tests',
236 'sympy.utilities.tests',
237 'sympy.plotting.tests',
240 setup(
241 name = 'sympy',
242 version = sympy.__version__,
243 description = 'Computer algebra system (CAS) in Python',
244 license = 'BSD',
245 url = 'http://code.google.com/p/sympy',
246 packages = ['sympy'] + [ m[1] for m in modules ] + tests,
247 scripts = ['bin/isympy'],
248 ext_modules = [],
249 data_files = [('share/man/man1', ['doc/man/isympy.1'])],
250 cmdclass = {'test': test_sympy,
251 'test_core' : test_sympy_core,
252 'test_doc' : test_sympy_doc,
253 'gen_doc' : gen_doc,
254 'clean' : clean,