##// END OF EJS Templates
Factor build logic into function
Matthias Bussonnier -
Show More
@@ -1,28 +1,32 b''
1 1 #!/usr/bin/env python
2 2 """IPython release build script.
3 3 """
4
5 4 import os
6 5 from shutil import rmtree
7 6
8 from toollib import sh, pjoin, get_ipdir, cd, compile_tree, execfile, sdists, wheels
7 from toollib import sh, pjoin, get_ipdir, cd, compile_tree, execfile, sdists, buildwheels
8
9 def build_release():
10
11 # Get main ipython dir, this will raise if it doesn't pass some checks
12 ipdir = get_ipdir()
13 cd(ipdir)
9 14
10 # Get main ipython dir, this will raise if it doesn't pass some checks
11 ipdir = get_ipdir()
12 cd(ipdir)
15 # Load release info
16 execfile(pjoin('IPython', 'core', 'release.py'), globals())
13 17
14 # Load release info
15 execfile(pjoin('IPython', 'core', 'release.py'), globals())
18 # Check that everything compiles
19 compile_tree('*')
16 20
17 # Check that everything compiles
18 compile_tree('*')
21 # Cleanup
22 for d in ['build', 'dist', pjoin('docs', 'build'), pjoin('docs', 'dist'),
23 pjoin('docs', 'source', 'api', 'generated')]:
24 if os.path.isdir(d):
25 rmtree(d)
19 26
20 # Cleanup
21 for d in ['build', 'dist', pjoin('docs', 'build'), pjoin('docs', 'dist'),
22 pjoin('docs', 'source', 'api', 'generated')]:
23 if os.path.isdir(d):
24 rmtree(d)
27 # Build source and binary distros
28 sh(sdists)
29 buildwheels()
25 30
26 # Build source and binary distros
27 sh(sdists)
28 sh(wheels)
31 if __name__ == '__main__':
32 build_release()
@@ -1,88 +1,88 b''
1 1 #!/usr/bin/env python
2 2 """IPython release script.
3 3
4 4 This should ONLY be run at real release time.
5 5 """
6 6 from __future__ import print_function
7 7
8 8 import os
9 9 import sys
10 10
11 11 from toollib import (get_ipdir, pjoin, cd, execfile, sh, archive,
12 sdists, archive_user, archive_dir)
12 sdists, archive_user, archive_dir, buildwheels)
13 13 from gh_api import post_download
14 14
15 15 # Get main ipython dir, this will raise if it doesn't pass some checks
16 16 ipdir = get_ipdir()
17 17 tooldir = pjoin(ipdir, 'tools')
18 18 distdir = pjoin(ipdir, 'dist')
19 19
20 20 # Where I keep static backups of each release
21 21 ipbackupdir = os.path.expanduser('~/ipython/backup')
22 22 if not os.path.exists(ipbackupdir):
23 23 os.makedirs(ipbackupdir)
24 24
25 25 # Start in main IPython dir
26 26 cd(ipdir)
27 27
28 28 # Load release info
29 29 version = None
30 30 execfile(pjoin('IPython','core','release.py'), globals())
31 31
32 32 # Build site addresses for file uploads
33 33 release_site = '%s/release/%s' % (archive, version)
34 34 backup_site = '%s/backup/' % archive
35 35
36 36 # Start actual release process
37 37 print()
38 38 print('Releasing IPython')
39 39 print('=================')
40 40 print()
41 41 print('Version:', version)
42 42 print()
43 43 print('Source IPython directory:', ipdir)
44 44 print()
45 45
46 46 # Perform local backup, go to tools dir to run it.
47 47 cd(tooldir)
48 48 sh('./make_tarball.py')
49 49 sh('mv ipython-*.tgz %s' % ipbackupdir)
50 50
51 51 # Build release files
52 52 sh('./build_release %s' % ipdir)
53 53
54 54 # Not Registering with PyPI, registering with setup.py is insecure as communication is not encrypted
55 55 cd(ipdir)
56 56
57 57 # Upload all files
58 58 sh(sdists)
59 for py in ('2', '3'):
60 sh('python%s setupegg.py bdist_wheel' % py)
59
60 buildwheels()
61 61
62 62 if 'upload' not in sys.argv:
63 63 print("`./release upload` to register and release")
64 64 sys.exit(0)
65 65
66 66
67 67 print('Will not upload with setuptools as upload connection is insecure. Please use `twine upload dist/*` to upload the files to PyPI')
68 68
69 69 cd(distdir)
70 70 print( 'Uploading distribution files to GitHub...')
71 71
72 72 for fname in os.listdir('.'):
73 73 # TODO: update to GitHub releases API
74 74 continue
75 75 print('uploading %s to GitHub' % fname)
76 76 desc = "IPython %s source distribution" % version
77 77 post_download("ipython/ipython", fname, description=desc)
78 78
79 79 # Make target dir if it doesn't exist
80 80 print('Uploading IPython to backup site.')
81 81 sh('ssh %s "mkdir -p %s/release/%s" ' % (archive_user, archive_dir, version))
82 82 sh('scp * %s' % release_site)
83 83
84 84 print( 'Uploading backup files...')
85 85 cd(ipbackupdir)
86 86 sh('scp `ls -1tr *tgz | tail -1` %s' % backup_site)
87 87
88 88 print('Done!')
@@ -1,64 +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 wheels = './setupegg.py bdist_wheel'
23 def buildwheels():
24 for py in ('2', '3'):
25 sh('python%s setupegg.py bdist_wheel' % py)
24 26
25 27 # Utility functions
26 28 def sh(cmd):
27 29 """Run system command in shell, raise SystemExit if it returns an error."""
28 30 print("$", cmd)
29 31 stat = os.system(cmd)
30 32 #stat = 0 # Uncomment this and comment previous to run in debug mode
31 33 if stat:
32 34 raise SystemExit("Command %s failed with code: %s" % (cmd, stat))
33 35
34 36 # Backwards compatibility
35 37 c = sh
36 38
37 39 def get_ipdir():
38 40 """Get IPython directory from command line, or assume it's the one above."""
39 41
40 42 # Initialize arguments and check location
41 43 ipdir = pjoin(os.path.dirname(__file__), os.pardir)
42 44
43 45 ipdir = os.path.abspath(ipdir)
44 46
45 47 cd(ipdir)
46 48 if not os.path.isdir('IPython') and os.path.isfile('setup.py'):
47 49 raise SystemExit('Invalid ipython directory: %s' % ipdir)
48 50 return ipdir
49 51
50 52
51 53 def compile_tree(folder='.'):
52 54 """Compile all Python files below current directory."""
53 55 stat = os.system('python -m compileall {}'.format(folder))
54 56 if stat:
55 57 msg = '*** ERROR: Some Python files in tree do NOT compile! ***\n'
56 58 msg += 'See messages above for the actual file that produced it.\n'
57 59 raise SystemExit(msg)
58 60
59 61 try:
60 62 execfile
61 63 except NameError:
62 64 def execfile(fname, globs, locs=None):
63 65 locs = locs or globs
64 66 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
General Comments 0
You need to be logged in to leave comments. Login now