Skip to content

Commit 8519425

Browse files
committed
Make setup/setupegg install isympy to isympy3
1 parent 7700c0f commit 8519425

File tree

3 files changed

+70
-43
lines changed

3 files changed

+70
-43
lines changed

setup.py

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929

3030
from distutils.core import setup
3131
from distutils.core import Command
32+
from distutils.command.build_scripts import build_scripts
3233
import sys
3334
import subprocess
3435
import os
3536

3637
import sympy
3738

39+
PY3 = sys.version_info[0] > 2
40+
3841
# Make sure I have the right Python version.
3942
if sys.version_info[:2] < (2, 6):
4043
print("SymPy requires Python 2.6 or newer. Python %d.%d detected" % sys.version_info[:2])
@@ -205,6 +208,32 @@ def run(self):
205208
from sympy.utilities import benchmarking
206209
benchmarking.main(['sympy'])
207210

211+
cmdclass = {'test': test_sympy,
212+
'bench': run_benchmarks,
213+
'clean': clean,
214+
'audit': audit}
215+
if PY3:
216+
class build_scripts_python3_suffix(build_scripts):
217+
def copy_scripts(self):
218+
outfiles, updated_files = build_scripts.copy_scripts(self)
219+
for outfile in outfiles:
220+
_, copied = self.copy_file(outfile, outfile + "3")
221+
if not self.dry_run and copied:
222+
try:
223+
os.unlink(outfile)
224+
except OSError:
225+
pass
226+
self.scripts = [outfile + "3" for outfile in outfiles]
227+
return outfiles, updated_files
228+
cmdclass['build_scripts'] = build_scripts_python3_suffix
229+
230+
if 'setuptools' in globals() and PY3:
231+
from setuptools.command.develop import develop
232+
class develop_python3_suffix(develop):
233+
def install_script(self, dist, script_name, script_text, dev_path=None):
234+
develop.install_script(self, dist, script_name + "3", script_text, dev_path)
235+
236+
cmdclass['develop'] = develop_python3_suffix
208237

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

276-
setup(
277-
name='sympy',
278-
version=sympy.__version__,
279-
description='Computer algebra system (CAS) in Python',
280-
long_description=long_description,
281-
author='SymPy development team',
282-
author_email='[email protected]',
283-
license='BSD',
284-
keywords="Math CAS",
285-
url='http://code.google.com/p/sympy',
286-
packages=['sympy'] + modules + tests,
287-
scripts=['bin/isympy'],
288-
ext_modules=[],
289-
package_data={ 'sympy.utilities.mathml': ['data/*.xsl'] },
290-
data_files=[('share/man/man1', ['doc/man/isympy.1'])],
291-
cmdclass={'test': test_sympy,
292-
'bench': run_benchmarks,
293-
'clean': clean,
294-
'audit': audit,
295-
},
296-
classifiers=classifiers,
297-
)
305+
setup_args = {
306+
"name": 'sympy',
307+
"version": sympy.__version__,
308+
"description": 'Computer algebra system (CAS) in Python',
309+
"long_description": long_description,
310+
"author": 'SymPy development team',
311+
"author_email": '[email protected]',
312+
"license": 'BSD',
313+
"keywords": "Math CAS",
314+
"url": 'http://code.google.com/p/sympy',
315+
"packages": ['sympy'] + modules + tests,
316+
"scripts": ['bin/isympy'],
317+
"ext_modules": [],
318+
"package_data": { 'sympy.utilities.mathml': ['data/*.xsl'] },
319+
"data_files": [('share/man/man1', ['doc/man/isympy.1'])],
320+
"cmdclass": cmdclass,
321+
"classifiers": classifiers,
322+
}
323+
324+
setup(**setup_args)

setupegg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import setuptools
22

3-
execfile('setup.py')
3+
exec(open('setup.py').read())

sympy/utilities/compilef.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def frange(*args, **kwargs):
310310
>>> frange('lambda x: sqrt(x)', 1, 4) # doctest: +ELLIPSIS
311311
<__main__.c_double_Array_3 object at ...>
312312
>>> for i in _:
313-
... print i
313+
... print(i)
314314
...
315315
1.0
316316
1.41421356237
@@ -544,8 +544,8 @@ def fbenchmark(f, var=[Symbol('x')]):
544544
global cf, pf, psyf
545545
start = time()
546546
cf = clambdify(var, f)
547-
print 'compile time (including sympy overhead): %f s' % (
548-
time() - start)
547+
print('compile time (including sympy overhead): %f s' % (
548+
time() - start))
549549
pf = lambdify(var, f, 'math')
550550
psyf = None
551551
psyco = import_module('psyco')
@@ -560,14 +560,14 @@ def fbenchmark(f, var=[Symbol('x')]):
560560
t3 = Timer(code, 'from __main__ import psyf as f')
561561
else:
562562
t3 = None
563-
print 'for x = (0, 1, 2, ..., 999)/1000'
564-
print '20 times in 3 runs'
565-
print 'compiled: %.4f %.4f %.4f' % tuple(t1.repeat(3, 20))
566-
print 'Python lambda: %.4f %.4f %.4f' % tuple(t2.repeat(3, 20))
563+
print('for x = (0, 1, 2, ..., 999)/1000')
564+
print('20 times in 3 runs')
565+
print('compiled: %.4f %.4f %.4f' % tuple(t1.repeat(3, 20)))
566+
print('Python lambda: %.4f %.4f %.4f' % tuple(t2.repeat(3, 20)))
567567
if t3:
568-
print 'Psyco lambda: %.4f %.4f %.4f' % tuple(t3.repeat(3, 20))
568+
print('Psyco lambda: %.4f %.4f %.4f' % tuple(t3.repeat(3, 20)))
569569

570-
print 'big function:'
570+
print('big function:')
571571
from sympy import _exp, _sin, _cos, pi, lambdify
572572
x = Symbol('x')
573573
## f1 = diff(_exp(x)**2 - _sin(x)**pi, x) \
@@ -577,33 +577,33 @@ def fbenchmark(f, var=[Symbol('x')]):
577577
+ 4*(10*pi**3*x**2 + 10*pi**2*x**3 + 5*pi*x**4 + 5*x*pi**4 + pi**5
578578
+ x**5)*_exp(123 + x + 2*x**4 - x**5) - 2*x**3 - 3*x**7
579579
fbenchmark(f1)
580-
print
581-
print 'simple function:'
580+
print()
581+
print('simple function:')
582582
y = Symbol('y')
583583
f2 = sqrt(x*y) + x*5
584584
fbenchmark(f2, [x, y])
585585
times = 100000
586586
fstr = '_exp(_sin(_exp(-x**2)) + sqrt(pi)*_cos(x**5/(x**3-x**2+pi*x)))'
587587
print
588-
print 'frange with f(x) ='
589-
print fstr
590-
print 'for x=1, ..., %i' % times
591-
print 'in 3 runs including full compile time'
588+
print('frange with f(x) =')
589+
print(fstr)
590+
print('for x=1, ..., %i' % times)
591+
print('in 3 runs including full compile time')
592592
t4 = Timer("frange('lambda x: %s', 0, %i)" % (fstr, times),
593593
'from __main__ import frange')
594594

595595
numpy = import_module('numpy')
596596

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

604604
if __name__ == '__main__':
605605
if __debug__:
606-
print 'Running tests...',
606+
print('Running tests...',)
607607
numpy = import_module('numpy')
608608
test_cexpr()
609609
test_clambdify()
@@ -614,7 +614,7 @@ def fbenchmark(f, var=[Symbol('x')]):
614614
test_use_cse()
615615
import doctest
616616
doctest.testmod()
617-
print 'OK'
617+
print('OK')
618618
print
619-
print 'Running benchmark...'
619+
print('Running benchmark...')
620620
benchmark()

0 commit comments

Comments
 (0)