risch: recognize Derivatives as components (#1012)
[sympy.git] / setup.py
blob61449d46714819ef0ac4d5fe0f8f9f3854e4fcfd
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', 'ast_parser'] ),
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.interactive', [] ),
56 ( True, 'sympy.matrices', [] ),
57 ( True, 'sympy.ntheory', [] ),
58 ( False, 'sympy.parsing', [] ),
59 ( True, 'sympy.physics', [] ),
60 ( False, 'sympy.plotting', [] ),
61 ( False, 'sympy.thirdparty', [] ),
62 ( False, 'sympy.mpmath', [] ),
63 ( True, 'sympy.polynomials', [] ),
64 ( True, 'sympy.polynomials.fast', [] ),
65 ( True, 'sympy.polys', ['wrappers'] ),
66 ( True, 'sympy.printing', ['gtk', 'tree'] ),
67 ( True, 'sympy.printing.pretty', [] ),
68 ( True, 'sympy.series', ["limits"] ),
69 ( True, 'sympy.simplify', [] ),
70 ( True, 'sympy.solvers', [] ),
71 ( True, 'sympy.statistics', [] ),
72 ( True, 'sympy.utilities', ["compilef"] ),
73 ( True, 'sympy.utilities.mathml', [] ),
76 class clean(Command):
77 """Cleans *.pyc and debian trashs, so you should get the same copy as
78 is in the svn.
79 """
81 description = "Clean everything"
82 user_options = [("all","a","the same")]
84 def initialize_options(self):
85 self.all = None
87 def finalize_options(self):
88 pass
90 def run(self):
91 import os
92 os.system("py.cleanup")
93 os.system("rm -f python-build-stamp-2.4")
94 os.system("rm -f MANIFEST")
95 os.system("rm -rf build")
96 os.system("rm -rf dist")
98 class gen_doc(Command):
99 """Generate the (html) api documentation using epydoc
101 output is sent to the directory ../api/
104 description = "generate the api doc"
105 user_options = []
107 target_dir = "../api/"
109 def initialize_options(self):
110 self.all = None
112 def finalize_options(self):
113 pass
115 def run(self):
116 import os
117 os.system("epydoc --no-frames -o %s sympy" % self.target_dir)
120 class test_sympy_core(Command):
121 """Run only the tests concerning features of sympy.core.
122 It's a lot faster than running the complete test suite.
125 description = "Automatically run the core test suite for Sympy."
126 user_options = [] # distutils complains if this is not here.
128 def initialize_options(self): # distutils wants this
129 pass
131 def finalize_options(self): # this too
132 pass
135 def run(self):
136 try:
137 import py
138 except ImportError:
139 print """In order to run the tests, you need codespeak's py.lib
140 web page: http://codespeak.net/py/dist/
141 If you are on debian systems, the package is named python-codespeak-lib
143 sys.exit(-1)
144 py.test.cmdline.main(args=["sympy/core/tests"])
147 class test_sympy(Command):
148 """Runs all tests under the sympy/ folder
151 description = "Automatically run the test suite for Sympy."
152 user_options = [] # distutils complains if this is not here.
154 def __init__(self, *args):
155 self.args = args[0] # so we can pass it to other classes
156 Command.__init__(self, *args)
158 def initialize_options(self): # distutils wants this
159 pass
161 def finalize_options(self): # this too
162 pass
164 def run(self):
165 try:
166 import py as pylib
167 except ImportError:
168 print """In order to run the tests, you need codespeak's py.lib
169 web page: http://codespeak.net/py/dist/
170 If you are on debian systems, the package is named python-codespeak-lib
172 sys.exit(-1)
173 pylib.test.cmdline.main(args=["sympy"])
174 tdoc = test_sympy_doc(self.args)
175 tdoc.run() # run also the doc test suite
177 class test_sympy_doc(Command):
179 description = "Run the tests for the examples in the documentation"
180 user_options = [] # distutils complains if this is not here.
182 def initialize_options(self): # distutils wants this
183 pass
185 def finalize_options(self): # this too
186 pass
188 def run(self):
189 import unittest
190 import doctest
192 import glob
194 print "Testing docstrings."
196 def setup_pprint():
197 from sympy import pprint_use_unicode
198 # force pprint to be in ascii mode in doctests
199 pprint_use_unicode(False)
201 # hook our nice, hash-stable strprinter
202 from sympy.interactive import init_printing
203 from sympy.printing import sstrrepr
204 init_printing(sstrrepr)
206 suite = unittest.TestSuite()
208 for perform, module, specific in modules:
209 if perform == True:
210 path = module.replace('.', '/')
212 items = glob.glob(path + '/[a-z][a-z0-9_]*.py')
213 items = [ i.replace('\\', '/') for i in items ]
215 for omit in specific:
216 items.remove(path + '/' + omit + '.py')
218 for item in items:
219 module = item.replace('/', '.')[:-3]
220 suite.addTest(doctest.DocTestSuite(module))
222 setup_pprint()
224 runner = unittest.TextTestRunner()
225 runner.run(suite)
227 # Check that this list is uptodate against the result of the command:
228 # $ python bin/generate_test_list.py
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.mpmath.tests',
239 'sympy.ntheory.tests',
240 'sympy.parsing.tests',
241 'sympy.physics.tests',
242 'sympy.plotting.tests',
243 'sympy.polynomials.tests',
244 'sympy.polys.tests',
245 'sympy.printing.pretty.tests',
246 'sympy.printing.tests',
247 'sympy.series.tests',
248 'sympy.simplify.tests',
249 'sympy.solvers.tests',
250 'sympy.statistics.tests',
251 'sympy.test_external',
252 'sympy.utilities.tests',
255 # update the following list from:
256 # http://pyglet.googlecode.com/svn/trunk/setup.py
257 # (whenever we update pyglet in sympy)
258 pyglet_packages=[
259 'pyglet',
260 'pyglet.gl',
261 'pyglet.font',
262 'pyglet.image',
263 'pyglet.image.codecs',
264 'pyglet.media',
265 'pyglet.media.drivers',
266 'pyglet.media.drivers.alsa',
267 'pyglet.media.drivers.directsound',
268 'pyglet.media.drivers.openal',
269 'pyglet.window',
270 'pyglet.window.carbon',
271 'pyglet.window.win32',
272 'pyglet.window.xlib',
274 pyglet_packages = ["sympy.thirdparty.pyglet." + s for s in pyglet_packages]
276 setup(
277 name = 'sympy',
278 version = sympy.__version__,
279 description = 'Computer algebra system (CAS) in Python',
280 license = 'BSD',
281 url = 'http://code.google.com/p/sympy',
282 packages = ['sympy'] + [ m[1] for m in modules ] + tests + \
283 pyglet_packages,
284 scripts = ['bin/isympy'],
285 ext_modules = [],
286 package_data = { 'sympy.utilities.mathml' : ['data/*.xsl'] },
287 data_files = [('share/man/man1', ['doc/man/isympy.1'])],
288 cmdclass = {'test': test_sympy,
289 'test_core' : test_sympy_core,
290 'test_doc' : test_sympy_doc,
291 'gen_doc' : gen_doc,
292 'clean' : clean,