##// END OF EJS Templates
Fix importing execfile from toollib on Python 2
Thomas Kluyver -
Show More
@@ -1,66 +1,66 b''
1 1 """Various utilities common to IPython release and maintenance tools.
2 2 """
3 3 from __future__ import print_function
4 4
5 5 # Library imports
6 6 import os
7 7
8 8 # Useful shorthands
9 9 pjoin = os.path.join
10 10 cd = os.chdir
11 11
12 12 # Constants
13 13
14 14 # SSH root address of the archive site
15 15 archive_user = 'ipython@archive.ipython.org'
16 16 archive_dir = 'archive.ipython.org'
17 17 archive = '%s:%s' % (archive_user, archive_dir)
18 18
19 19 # Build commands
20 20 # Source dists
21 21 sdists = './setup.py sdist --formats=gztar,zip'
22 22 # Binary dists
23 23 def buildwheels():
24 24 for py in ('2', '3'):
25 25 sh('python%s setupegg.py bdist_wheel' % py)
26 26
27 27 # Utility functions
28 28 def sh(cmd):
29 29 """Run system command in shell, raise SystemExit if it returns an error."""
30 30 print("$", cmd)
31 31 stat = os.system(cmd)
32 32 #stat = 0 # Uncomment this and comment previous to run in debug mode
33 33 if stat:
34 34 raise SystemExit("Command %s failed with code: %s" % (cmd, stat))
35 35
36 36 # Backwards compatibility
37 37 c = sh
38 38
39 39 def get_ipdir():
40 40 """Get IPython directory from command line, or assume it's the one above."""
41 41
42 42 # Initialize arguments and check location
43 43 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
44 44
45 45 ipdir = os.path.abspath(ipdir)
46 46
47 47 cd(ipdir)
48 48 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
49 49 raise SystemExit('Invalid ipython directory: %s' % ipdir)
50 50 return ipdir
51 51
52 52
53 53 def compile_tree(folder='.'):
54 54 """Compile all Python files below current directory."""
55 55 stat = os.system('python -m compileall {}'.format(folder))
56 56 if stat:
57 57 msg = '*** ERROR: Some Python files in tree do NOT compile! ***\n'
58 58 msg += 'See messages above for the actual file that produced it.\n'
59 59 raise SystemExit(msg)
60 60
61 61 try:
62 execfile
62 execfile = execfile
63 63 except NameError:
64 64 def execfile(fname, globs, locs=None):
65 65 locs = locs or globs
66 66 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
General Comments 0
You need to be logged in to leave comments. Login now