Implemented crisscross algorithm for solving LP problems.
[sympycore.git] / setup.py
blob6238dad55463748fac414abe1ccd5e67b0f0b45c
1 #!/usr/bin/env python
3 CLASSIFIERS = """\
4 Development Status :: 3 - Alpha
5 Intended Audience :: Science/Research
6 License :: OSI Approved
7 Programming Language :: Python
8 Topic :: Scientific/Engineering
9 Topic :: Software Development
10 Operating System :: Microsoft :: Windows
11 Operating System :: POSIX
12 Operating System :: Unix
13 Operating System :: MacOS
14 """
16 import os
17 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
19 from distutils.core import Extension, Command
20 from distutils.command.build_py import build_py as _build_py
22 expr_ext = Extension('sympycore.expr_ext',
23 sources = [os.path.join('src','expr_ext.c')],
26 combinatorics_ext = Extension('sympycore.arithmetic.combinatorics',
27 sources = [os.path.join('sympycore','arithmetic','combinatorics.c')],
30 extensions = [expr_ext,
31 #combinatorics_ext
34 packages = ['sympycore',
35 'sympycore.algebras',
36 'sympycore.arithmetic',
37 'sympycore.arithmetic.mpmath',
38 'sympycore.arithmetic.mpmath.calculus',
39 'sympycore.arithmetic.mpmath.functions',
40 'sympycore.arithmetic.mpmath.libmp',
41 'sympycore.arithmetic.mpmath.matrices',
42 'sympycore.basealgebra',
43 'sympycore.calculus',
44 'sympycore.calculus.functions',
45 'sympycore.functions',
46 'sympycore.heads',
47 'sympycore.logic',
48 'sympycore.matrices',
49 'sympycore.polynomials',
50 'sympycore.physics',
51 'sympycore.physics.sysbio',
52 'sympycore.ring',
53 'sympycore.sets',
56 packages += [p+'.tests' for p in packages \
57 if os.path.exists(os.path.join(p.replace('.', os.sep), 'tests'))]
59 class tester(Command):
60 description = "run sympycore tests"
61 user_options = [('nose-args=', 'n', 'arguments to nose command'),
62 ('with-coverage', 'c', 'use nose --with-coverage flag'),
63 ('cover-package=', None, 'use nose --cover-package flag'),
64 ('detailed-errors', 'd', 'use nose --detailed-errors flag'),
65 ('nocapture', 's', 'use nose --nocapture flag'),
66 ('nose-verbose', 'v', 'use nose --verbose flag'),
67 ('match=', 'm', 'use nose --match flag'),
68 ('profile', 'p', 'use nose --profile flag'),
69 ('with-doctest', None, 'use nose --with-doctest flag'),
70 ('stop', 'x', 'use nose --stop flag')
72 def initialize_options(self):
73 self.nose_args = None
74 self.with_coverage = None
75 self.cover_package = None
76 self.detailed_errors = None
77 self.nocapture = None
78 self.nose_verbose = None
79 self.match = None
80 self.profile = None
81 self.with_doctest = None
82 self.stop = None
83 return
84 def finalize_options (self):
85 if self.nose_args is None:
86 self.nose_args = ''
87 if self.with_coverage:
88 self.nose_args += ' --with-coverage'
89 if self.cover_package:
90 if not self.with_coverage:
91 self.nose_args += ' --with-coverage'
92 self.nose_args += ' --cover-package=%s' % self.cover_package
93 elif self.with_coverage:
94 self.nose_args += ' --cover-package=sympycore'
95 if self.detailed_errors:
96 self.nose_args += ' --detailed-errors'
97 if self.nocapture:
98 self.nose_args += ' --nocapture'
99 if self.nose_verbose:
100 self.nose_args += ' --verbose'
101 if self.match:
102 self.nose_args += ' --match=%r' % (self.match)
103 if self.profile:
104 self.nose_args += ' --with-profile'
105 if self.with_doctest:
106 self.nose_args += ' --with-doctest'
107 if self.stop:
108 self.nose_args += ' --stop'
109 return
110 def run(self):
111 import sympycore
112 sympycore.test(nose_args=self.nose_args)
114 class build_py(_build_py):
116 def find_data_files (self, package, src_dir):
118 files = _build_py.find_data_files(self, package, src_dir)
120 if package=='sympycore':
121 revision = self._get_svn_revision(src_dir)
122 if revision is not None:
123 target = os.path.join(src_dir, '__svn_version__.py')
124 print 'Creating ', target
125 f = open(target,'w')
126 f.write('version = %r\n' % (str(revision)))
127 f.close()
128 import atexit
129 def rm_file(f=target):
130 try: os.remove(f); print 'Removed ',f
131 except OSError: pass
132 try: os.remove(f+'c'); print 'Removed ',f+'c'
133 except OSError: pass
134 atexit.register(rm_file)
135 files.append(target)
137 if package=='sympycore.arithmetic.mpmath':
138 f = os.path.join(src_dir, 'REVISION')
139 if os.path.isfile(f):
140 files.append(f)
142 return files
144 def _get_svn_revision(self, path):
145 """Return path's SVN revision number.
147 import os, sys, re
148 revision = None
149 m = None
150 try:
151 sin, sout = os.popen4('svnversion')
152 m = re.match(r'(?P<revision>\d+)', sout.read())
153 except:
154 pass
155 if m:
156 revision = int(m.group('revision'))
157 return revision
158 if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK',None):
159 entries = os.path.join(path,'_svn','entries')
160 else:
161 entries = os.path.join(path,'.svn','entries')
162 if os.path.isfile(entries):
163 f = open(entries)
164 fstr = f.read()
165 f.close()
166 if fstr[:5] == '<?xml': # pre 1.4
167 m = re.search(r'revision="(?P<revision>\d+)"',fstr)
168 if m:
169 revision = int(m.group('revision'))
170 else: # non-xml entries file --- check to be sure that
171 m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr)
172 if m:
173 revision = int(m.group('revision'))
174 return revision
177 if __name__ == '__main__':
178 from distutils.core import setup
179 setup(name='sympycore',
180 version='0.2-svn',
181 author = 'Pearu Peterson, Fredrik Johansson',
182 author_email = 'sympycore@googlegroups.com',
183 license = 'http://sympycore.googlecode.com/svn/trunk/LICENSE',
184 url = 'http://sympycore.googlecode.com',
185 download_url = 'http://code.google.com/p/sympycore/downloads/',
186 classifiers=filter(None, CLASSIFIERS.split('\n')),
187 description = 'SympyCore: an efficient pure Python Computer Algebra System',
188 long_description = '''\
189 SympyCore project provides a pure Python package sympycore for
190 representing symbolic expressions using efficient data structures as
191 well as methods to manipulate them. Sympycore uses a clear algebra
192 oriented design that can be easily extended.
193 ''',
194 platforms = ["All"],
195 packages = packages,
196 ext_modules = extensions,
197 package_dir = {'sympycore': 'sympycore'},
198 cmdclass=dict(test=tester, build_py=build_py)