Skip to content

Commit

Permalink
Make setup/setupegg install isympy to isympy3
Browse files Browse the repository at this point in the history
  • Loading branch information
flacjacket committed Jul 26, 2013
1 parent 7700c0f commit 8519425
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 43 deletions.
71 changes: 49 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@

from distutils.core import setup
from distutils.core import Command
from distutils.command.build_scripts import build_scripts
import sys
import subprocess
import os

import sympy

PY3 = sys.version_info[0] > 2

# Make sure I have the right Python version.
if sys.version_info[:2] < (2, 6):
print("SymPy requires Python 2.6 or newer. Python %d.%d detected" % sys.version_info[:2])
Expand Down Expand Up @@ -205,6 +208,32 @@ def run(self):
from sympy.utilities import benchmarking
benchmarking.main(['sympy'])

cmdclass = {'test': test_sympy,
'bench': run_benchmarks,
'clean': clean,
'audit': audit}
if PY3:
class build_scripts_python3_suffix(build_scripts):
def copy_scripts(self):
outfiles, updated_files = build_scripts.copy_scripts(self)
for outfile in outfiles:
_, copied = self.copy_file(outfile, outfile + "3")
if not self.dry_run and copied:
try:
os.unlink(outfile)
except OSError:
pass
self.scripts = [outfile + "3" for outfile in outfiles]
return outfiles, updated_files
cmdclass['build_scripts'] = build_scripts_python3_suffix

if 'setuptools' in globals() and PY3:
from setuptools.command.develop import develop
class develop_python3_suffix(develop):
def install_script(self, dist, script_name, script_text, dev_path=None):
develop.install_script(self, dist, script_name + "3", script_text, dev_path)

cmdclass['develop'] = develop_python3_suffix

# Check that this list is uptodate against the result of the command:
# $ python bin/generate_test_list.py
Expand Down Expand Up @@ -273,25 +302,23 @@ def run(self):
as simple as possible in order to be comprehensible and easily extensible.
SymPy is written entirely in Python and does not require any external libraries.'''

setup(
name='sympy',
version=sympy.__version__,
description='Computer algebra system (CAS) in Python',
long_description=long_description,
author='SymPy development team',
author_email='[email protected]',
license='BSD',
keywords="Math CAS",
url='http://code.google.com/p/sympy',
packages=['sympy'] + modules + tests,
scripts=['bin/isympy'],
ext_modules=[],
package_data={ 'sympy.utilities.mathml': ['data/*.xsl'] },
data_files=[('share/man/man1', ['doc/man/isympy.1'])],
cmdclass={'test': test_sympy,
'bench': run_benchmarks,
'clean': clean,
'audit': audit,
},
classifiers=classifiers,
)
setup_args = {
"name": 'sympy',
"version": sympy.__version__,
"description": 'Computer algebra system (CAS) in Python',
"long_description": long_description,
"author": 'SymPy development team',
"author_email": '[email protected]',
"license": 'BSD',
"keywords": "Math CAS",
"url": 'http://code.google.com/p/sympy',
"packages": ['sympy'] + modules + tests,
"scripts": ['bin/isympy'],
"ext_modules": [],
"package_data": { 'sympy.utilities.mathml': ['data/*.xsl'] },
"data_files": [('share/man/man1', ['doc/man/isympy.1'])],
"cmdclass": cmdclass,
"classifiers": classifiers,
}

setup(**setup_args)
2 changes: 1 addition & 1 deletion setupegg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import setuptools

execfile('setup.py')
exec(open('setup.py').read())
40 changes: 20 additions & 20 deletions sympy/utilities/compilef.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def frange(*args, **kwargs):
>>> frange('lambda x: sqrt(x)', 1, 4) # doctest: +ELLIPSIS
<__main__.c_double_Array_3 object at ...>
>>> for i in _:
... print i
... print(i)
...
1.0
1.41421356237
Expand Down Expand Up @@ -544,8 +544,8 @@ def fbenchmark(f, var=[Symbol('x')]):
global cf, pf, psyf
start = time()
cf = clambdify(var, f)
print 'compile time (including sympy overhead): %f s' % (
time() - start)
print('compile time (including sympy overhead): %f s' % (
time() - start))
pf = lambdify(var, f, 'math')
psyf = None
psyco = import_module('psyco')
Expand All @@ -560,14 +560,14 @@ def fbenchmark(f, var=[Symbol('x')]):
t3 = Timer(code, 'from __main__ import psyf as f')
else:
t3 = None
print 'for x = (0, 1, 2, ..., 999)/1000'
print '20 times in 3 runs'
print 'compiled: %.4f %.4f %.4f' % tuple(t1.repeat(3, 20))
print 'Python lambda: %.4f %.4f %.4f' % tuple(t2.repeat(3, 20))
print('for x = (0, 1, 2, ..., 999)/1000')
print('20 times in 3 runs')
print('compiled: %.4f %.4f %.4f' % tuple(t1.repeat(3, 20)))
print('Python lambda: %.4f %.4f %.4f' % tuple(t2.repeat(3, 20)))
if t3:
print 'Psyco lambda: %.4f %.4f %.4f' % tuple(t3.repeat(3, 20))
print('Psyco lambda: %.4f %.4f %.4f' % tuple(t3.repeat(3, 20)))

print 'big function:'
print('big function:')
from sympy import _exp, _sin, _cos, pi, lambdify
x = Symbol('x')
## f1 = diff(_exp(x)**2 - _sin(x)**pi, x) \
Expand All @@ -577,33 +577,33 @@ def fbenchmark(f, var=[Symbol('x')]):
+ 4*(10*pi**3*x**2 + 10*pi**2*x**3 + 5*pi*x**4 + 5*x*pi**4 + pi**5
+ x**5)*_exp(123 + x + 2*x**4 - x**5) - 2*x**3 - 3*x**7
fbenchmark(f1)
print
print 'simple function:'
print()
print('simple function:')
y = Symbol('y')
f2 = sqrt(x*y) + x*5
fbenchmark(f2, [x, y])
times = 100000
fstr = '_exp(_sin(_exp(-x**2)) + sqrt(pi)*_cos(x**5/(x**3-x**2+pi*x)))'
print
print 'frange with f(x) ='
print fstr
print 'for x=1, ..., %i' % times
print 'in 3 runs including full compile time'
print('frange with f(x) =')
print(fstr)
print('for x=1, ..., %i' % times)
print('in 3 runs including full compile time')
t4 = Timer("frange('lambda x: %s', 0, %i)" % (fstr, times),
'from __main__ import frange')

numpy = import_module('numpy')

print 'frange: %.4f %.4f %.4f' % tuple(t4.repeat(3, 1))
print('frange: %.4f %.4f %.4f' % tuple(t4.repeat(3, 1)))
if numpy:
t5 = Timer('x = arange(%i); result = %s' % (times, fstr),
'from numpy import arange, sqrt, exp, sin, cos, exp, pi')
print 'numpy: %.4f %.4f %.4f' % tuple(t5.repeat(3, 1))
print('numpy: %.4f %.4f %.4f' % tuple(t5.repeat(3, 1)))
# TODO: integration into fbenchmark

if __name__ == '__main__':
if __debug__:
print 'Running tests...',
print('Running tests...',)
numpy = import_module('numpy')
test_cexpr()
test_clambdify()
Expand All @@ -614,7 +614,7 @@ def fbenchmark(f, var=[Symbol('x')]):
test_use_cse()
import doctest
doctest.testmod()
print 'OK'
print('OK')
print
print 'Running benchmark...'
print('Running benchmark...')
benchmark()

0 comments on commit 8519425

Please sign in to comment.