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