Show More
@@ -1,103 +1,92 b'' | |||||
1 | """utilities for checking submodule status""" |
|
1 | """utilities for checking submodule status""" | |
2 |
|
2 | |||
3 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
4 | # Copyright (C) 2013 The IPython Development Team |
|
4 | # Copyright (C) 2013 The IPython Development Team | |
5 | # |
|
5 | # | |
6 | # Distributed under the terms of the BSD License. The full license is in |
|
6 | # Distributed under the terms of the BSD License. The full license is in | |
7 | # the file COPYING, distributed as part of this software. |
|
7 | # the file COPYING, distributed as part of this software. | |
8 | #----------------------------------------------------------------------------- |
|
8 | #----------------------------------------------------------------------------- | |
9 |
|
9 | |||
10 | #----------------------------------------------------------------------------- |
|
10 | #----------------------------------------------------------------------------- | |
11 | # Imports |
|
11 | # Imports | |
12 | #----------------------------------------------------------------------------- |
|
12 | #----------------------------------------------------------------------------- | |
13 |
|
13 | |||
14 | import os |
|
14 | import os | |
15 | import subprocess |
|
15 | import subprocess | |
16 | import sys |
|
16 | import sys | |
17 |
|
17 | |||
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 | # Globals |
|
19 | # Globals | |
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
21 |
|
21 | |||
22 | pjoin = os.path.join |
|
22 | pjoin = os.path.join | |
23 |
|
23 | |||
24 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
25 | # Code |
|
25 | # Code | |
26 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
27 |
|
27 | |||
28 | def ipython_parent(): |
|
28 | def ipython_parent(): | |
29 | """return IPython's parent (i.e. root if run from git)""" |
|
29 | """return IPython's parent (i.e. root if run from git)""" | |
30 | from IPython.utils.path import get_ipython_package_dir |
|
30 | from IPython.utils.path import get_ipython_package_dir | |
31 | return os.path.abspath(os.path.dirname(get_ipython_package_dir())) |
|
31 | return os.path.abspath(os.path.dirname(get_ipython_package_dir())) | |
32 |
|
32 | |||
33 | def ipython_submodules(root): |
|
33 | def ipython_submodules(root): | |
34 | """return IPython submodules relative to root""" |
|
34 | """return IPython submodules relative to root""" | |
35 | from IPython.frontend.html.notebook import DEFAULT_STATIC_FILES_PATH |
|
|||
36 | return [ |
|
35 | return [ | |
37 | pjoin(DEFAULT_STATIC_FILES_PATH, 'components') |
|
36 | pjoin(root, 'IPython', 'frontend', 'html', 'notebook', 'static', 'components'), | |
38 | ] |
|
37 | ] | |
39 |
|
38 | |||
40 | def is_repo(d): |
|
39 | def is_repo(d): | |
41 | """is d a git repo?""" |
|
40 | """is d a git repo?""" | |
42 | return os.path.exists(pjoin(d, '.git')) |
|
41 | return os.path.exists(pjoin(d, '.git')) | |
43 |
|
42 | |||
44 | def is_package(): |
|
|||
45 | """Is a package manager responsible for the static files path?""" |
|
|||
46 | from IPython.utils.path import get_ipython_package_dir |
|
|||
47 | from IPython.frontend.html.notebook import DEFAULT_STATIC_FILES_PATH |
|
|||
48 | return not DEFAULT_STATIC_FILES_PATH.startswith(get_ipython_package_dir()) |
|
|||
49 |
|
||||
50 | def check_submodule_status(root=None): |
|
43 | def check_submodule_status(root=None): | |
51 | """check submodule status |
|
44 | """check submodule status | |
52 |
|
45 | |||
53 | Has three return values: |
|
46 | Has three return values: | |
54 |
|
47 | |||
55 | 'missing' - submodules are absent |
|
48 | 'missing' - submodules are absent | |
56 | 'unclean' - submodules have unstaged changes |
|
49 | 'unclean' - submodules have unstaged changes | |
57 | 'clean' - all submodules are up to date |
|
50 | 'clean' - all submodules are up to date | |
58 | """ |
|
51 | """ | |
59 |
|
52 | |||
60 | if hasattr(sys, "frozen"): |
|
53 | if hasattr(sys, "frozen"): | |
61 | # frozen via py2exe or similar, don't bother |
|
54 | # frozen via py2exe or similar, don't bother | |
62 | return 'clean' |
|
55 | return 'clean' | |
63 |
|
||||
64 | if is_package(): |
|
|||
65 | # package manager is responsible for static files, don't bother |
|
|||
66 | return 'clean' |
|
|||
67 |
|
56 | |||
68 | if not root: |
|
57 | if not root: | |
69 | root = ipython_parent() |
|
58 | root = ipython_parent() | |
|
59 | ||||
|
60 | if not is_repo(root): | |||
|
61 | # not in git, assume clean | |||
|
62 | return 'clean' | |||
70 |
|
63 | |||
71 | submodules = ipython_submodules(root) |
|
64 | submodules = ipython_submodules(root) | |
72 |
|
65 | |||
73 | for submodule in submodules: |
|
66 | for submodule in submodules: | |
74 | if not os.path.exists(submodule): |
|
67 | if not os.path.exists(submodule): | |
75 | return 'missing' |
|
68 | return 'missing' | |
76 |
|
69 | |||
77 | if not is_repo(root): |
|
|||
78 | # not in git, assume clean |
|
|||
79 | return 'clean' |
|
|||
80 |
|
||||
81 | # check with git submodule status |
|
70 | # check with git submodule status | |
82 | proc = subprocess.Popen('git submodule status', |
|
71 | proc = subprocess.Popen('git submodule status', | |
83 | stdout=subprocess.PIPE, |
|
72 | stdout=subprocess.PIPE, | |
84 | stderr=subprocess.PIPE, |
|
73 | stderr=subprocess.PIPE, | |
85 | shell=True, |
|
74 | shell=True, | |
86 | cwd=root, |
|
75 | cwd=root, | |
87 | ) |
|
76 | ) | |
88 | status, _ = proc.communicate() |
|
77 | status, _ = proc.communicate() | |
89 | status = status.decode("ascii") |
|
78 | status = status.decode("ascii") | |
90 |
|
79 | |||
91 | for line in status.splitlines(): |
|
80 | for line in status.splitlines(): | |
92 | if status.startswith('-'): |
|
81 | if status.startswith('-'): | |
93 | return 'missing' |
|
82 | return 'missing' | |
94 | elif status.startswith('+'): |
|
83 | elif status.startswith('+'): | |
95 | return 'unclean' |
|
84 | return 'unclean' | |
96 |
|
85 | |||
97 | return 'clean' |
|
86 | return 'clean' | |
98 |
|
87 | |||
99 | def update_submodules(repo_dir): |
|
88 | def update_submodules(repo_dir): | |
100 | """update submodules in a repo""" |
|
89 | """update submodules in a repo""" | |
101 | subprocess.check_call("git submodule init", cwd=repo_dir, shell=True) |
|
90 | subprocess.check_call("git submodule init", cwd=repo_dir, shell=True) | |
102 | subprocess.check_call("git submodule update --recursive", cwd=repo_dir, shell=True) |
|
91 | subprocess.check_call("git submodule update --recursive", cwd=repo_dir, shell=True) | |
103 |
|
92 |
@@ -1,345 +1,347 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | # -*- coding: utf-8 -*- |
|
2 | # -*- coding: utf-8 -*- | |
3 | """Setup script for IPython. |
|
3 | """Setup script for IPython. | |
4 |
|
4 | |||
5 | Under Posix environments it works like a typical setup.py script. |
|
5 | Under Posix environments it works like a typical setup.py script. | |
6 | Under Windows, the command sdist is not supported, since IPython |
|
6 | Under Windows, the command sdist is not supported, since IPython | |
7 | requires utilities which are not available under Windows.""" |
|
7 | requires utilities which are not available under Windows.""" | |
8 |
|
8 | |||
9 | #----------------------------------------------------------------------------- |
|
9 | #----------------------------------------------------------------------------- | |
10 | # Copyright (c) 2008-2011, IPython Development Team. |
|
10 | # Copyright (c) 2008-2011, IPython Development Team. | |
11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> | |
12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> | |
13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> | |
14 | # |
|
14 | # | |
15 | # Distributed under the terms of the Modified BSD License. |
|
15 | # Distributed under the terms of the Modified BSD License. | |
16 | # |
|
16 | # | |
17 | # The full license is in the file COPYING.txt, distributed with this software. |
|
17 | # The full license is in the file COPYING.txt, distributed with this software. | |
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
21 | # Minimal Python version sanity check |
|
21 | # Minimal Python version sanity check | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 | from __future__ import print_function |
|
23 | from __future__ import print_function | |
24 |
|
24 | |||
25 | import sys |
|
25 | import sys | |
26 |
|
26 | |||
27 | # This check is also made in IPython/__init__, don't forget to update both when |
|
27 | # This check is also made in IPython/__init__, don't forget to update both when | |
28 | # changing Python version requirements. |
|
28 | # changing Python version requirements. | |
29 | #~ if sys.version[0:3] < '2.6': |
|
29 | #~ if sys.version[0:3] < '2.6': | |
30 | #~ error = """\ |
|
30 | #~ error = """\ | |
31 | #~ ERROR: 'IPython requires Python Version 2.6 or above.' |
|
31 | #~ ERROR: 'IPython requires Python Version 2.6 or above.' | |
32 | #~ Exiting.""" |
|
32 | #~ Exiting.""" | |
33 | #~ print >> sys.stderr, error |
|
33 | #~ print >> sys.stderr, error | |
34 | #~ sys.exit(1) |
|
34 | #~ sys.exit(1) | |
35 |
|
35 | |||
36 | PY3 = (sys.version_info[0] >= 3) |
|
36 | PY3 = (sys.version_info[0] >= 3) | |
37 |
|
37 | |||
38 | # At least we're on the python version we need, move on. |
|
38 | # At least we're on the python version we need, move on. | |
39 |
|
39 | |||
40 | #------------------------------------------------------------------------------- |
|
40 | #------------------------------------------------------------------------------- | |
41 | # Imports |
|
41 | # Imports | |
42 | #------------------------------------------------------------------------------- |
|
42 | #------------------------------------------------------------------------------- | |
43 |
|
43 | |||
44 | # Stdlib imports |
|
44 | # Stdlib imports | |
45 | import os |
|
45 | import os | |
46 | import shutil |
|
46 | import shutil | |
47 |
|
47 | |||
48 | from glob import glob |
|
48 | from glob import glob | |
49 |
|
49 | |||
50 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
50 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | |
51 | # update it when the contents of directories change. |
|
51 | # update it when the contents of directories change. | |
52 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
52 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') | |
53 |
|
53 | |||
54 | from distutils.core import setup |
|
54 | from distutils.core import setup | |
55 |
|
55 | |||
56 | # On Python 3, we need distribute (new setuptools) to do the 2to3 conversion |
|
56 | # On Python 3, we need distribute (new setuptools) to do the 2to3 conversion | |
57 | if PY3: |
|
57 | if PY3: | |
58 | import setuptools |
|
58 | import setuptools | |
59 |
|
59 | |||
60 | # Our own imports |
|
60 | # Our own imports | |
61 | from setupbase import target_update |
|
61 | from setupbase import target_update | |
62 |
|
62 | |||
63 | from setupbase import ( |
|
63 | from setupbase import ( | |
64 | setup_args, |
|
64 | setup_args, | |
65 | find_packages, |
|
65 | find_packages, | |
66 | find_package_data, |
|
66 | find_package_data, | |
67 | find_scripts, |
|
67 | find_scripts, | |
68 | find_data_files, |
|
68 | find_data_files, | |
69 | check_for_dependencies, |
|
69 | check_for_dependencies, | |
70 | git_prebuild, |
|
70 | git_prebuild, | |
71 | check_submodule_status, |
|
71 | check_submodule_status, | |
72 | update_submodules, |
|
72 | update_submodules, | |
73 | require_submodules, |
|
73 | require_submodules, | |
74 | UpdateSubmodules, |
|
74 | UpdateSubmodules, | |
75 | ) |
|
75 | ) | |
76 | from setupext import setupext |
|
76 | from setupext import setupext | |
77 |
|
77 | |||
78 | isfile = os.path.isfile |
|
78 | isfile = os.path.isfile | |
79 | pjoin = os.path.join |
|
79 | pjoin = os.path.join | |
80 |
|
80 | |||
81 | #----------------------------------------------------------------------------- |
|
81 | #----------------------------------------------------------------------------- | |
82 | # Function definitions |
|
82 | # Function definitions | |
83 | #----------------------------------------------------------------------------- |
|
83 | #----------------------------------------------------------------------------- | |
84 |
|
84 | |||
85 | def cleanup(): |
|
85 | def cleanup(): | |
86 | """Clean up the junk left around by the build process""" |
|
86 | """Clean up the junk left around by the build process""" | |
87 | if "develop" not in sys.argv and "egg_info" not in sys.argv: |
|
87 | if "develop" not in sys.argv and "egg_info" not in sys.argv: | |
88 | try: |
|
88 | try: | |
89 | shutil.rmtree('ipython.egg-info') |
|
89 | shutil.rmtree('ipython.egg-info') | |
90 | except: |
|
90 | except: | |
91 | try: |
|
91 | try: | |
92 | os.unlink('ipython.egg-info') |
|
92 | os.unlink('ipython.egg-info') | |
93 | except: |
|
93 | except: | |
94 | pass |
|
94 | pass | |
95 |
|
95 | |||
96 | #------------------------------------------------------------------------------- |
|
96 | #------------------------------------------------------------------------------- | |
97 | # Handle OS specific things |
|
97 | # Handle OS specific things | |
98 | #------------------------------------------------------------------------------- |
|
98 | #------------------------------------------------------------------------------- | |
99 |
|
99 | |||
100 | if os.name in ('nt','dos'): |
|
100 | if os.name in ('nt','dos'): | |
101 | os_name = 'windows' |
|
101 | os_name = 'windows' | |
102 | else: |
|
102 | else: | |
103 | os_name = os.name |
|
103 | os_name = os.name | |
104 |
|
104 | |||
105 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
105 | # Under Windows, 'sdist' has not been supported. Now that the docs build with | |
106 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
106 | # Sphinx it might work, but let's not turn it on until someone confirms that it | |
107 | # actually works. |
|
107 | # actually works. | |
108 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
108 | if os_name == 'windows' and 'sdist' in sys.argv: | |
109 | print('The sdist command is not available under Windows. Exiting.') |
|
109 | print('The sdist command is not available under Windows. Exiting.') | |
110 | sys.exit(1) |
|
110 | sys.exit(1) | |
111 |
|
111 | |||
112 | #------------------------------------------------------------------------------- |
|
112 | #------------------------------------------------------------------------------- | |
113 | # Make sure we aren't trying to run without submodules |
|
113 | # Make sure we aren't trying to run without submodules | |
114 | #------------------------------------------------------------------------------- |
|
114 | #------------------------------------------------------------------------------- | |
115 | here = os.path.abspath(os.path.dirname(__file__)) |
|
115 | here = os.path.abspath(os.path.dirname(__file__)) | |
116 |
|
116 | |||
117 | def require_clean_submodules(): |
|
117 | def require_clean_submodules(): | |
118 | """Check on git submodules before distutils can do anything |
|
118 | """Check on git submodules before distutils can do anything | |
119 |
|
119 | |||
120 | Since distutils cannot be trusted to update the tree |
|
120 | Since distutils cannot be trusted to update the tree | |
121 | after everything has been set in motion, |
|
121 | after everything has been set in motion, | |
122 | this is not a distutils command. |
|
122 | this is not a distutils command. | |
123 | """ |
|
123 | """ | |
|
124 | # PACKAGERS: Add a return here to skip checks for git submodules | |||
|
125 | ||||
124 | # don't do anything if nothing is actually supposed to happen |
|
126 | # don't do anything if nothing is actually supposed to happen | |
125 | for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'): |
|
127 | for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'): | |
126 | if do_nothing in sys.argv: |
|
128 | if do_nothing in sys.argv: | |
127 | return |
|
129 | return | |
128 |
|
130 | |||
129 | status = check_submodule_status(here) |
|
131 | status = check_submodule_status(here) | |
130 |
|
132 | |||
131 | if status == "missing": |
|
133 | if status == "missing": | |
132 | print("checking out submodules for the first time") |
|
134 | print("checking out submodules for the first time") | |
133 | update_submodules(here) |
|
135 | update_submodules(here) | |
134 | elif status == "unclean": |
|
136 | elif status == "unclean": | |
135 | print('\n'.join([ |
|
137 | print('\n'.join([ | |
136 | "Cannot build / install IPython with unclean submodules", |
|
138 | "Cannot build / install IPython with unclean submodules", | |
137 | "Please update submodules with", |
|
139 | "Please update submodules with", | |
138 | " python setup.py submodule", |
|
140 | " python setup.py submodule", | |
139 | "or", |
|
141 | "or", | |
140 | " git submodule update", |
|
142 | " git submodule update", | |
141 | "or commit any submodule changes you have made." |
|
143 | "or commit any submodule changes you have made." | |
142 | ])) |
|
144 | ])) | |
143 | sys.exit(1) |
|
145 | sys.exit(1) | |
144 |
|
146 | |||
145 | require_clean_submodules() |
|
147 | require_clean_submodules() | |
146 |
|
148 | |||
147 | #------------------------------------------------------------------------------- |
|
149 | #------------------------------------------------------------------------------- | |
148 | # Things related to the IPython documentation |
|
150 | # Things related to the IPython documentation | |
149 | #------------------------------------------------------------------------------- |
|
151 | #------------------------------------------------------------------------------- | |
150 |
|
152 | |||
151 | # update the manuals when building a source dist |
|
153 | # update the manuals when building a source dist | |
152 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
154 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): | |
153 | import textwrap |
|
155 | import textwrap | |
154 |
|
156 | |||
155 | # List of things to be updated. Each entry is a triplet of args for |
|
157 | # List of things to be updated. Each entry is a triplet of args for | |
156 | # target_update() |
|
158 | # target_update() | |
157 | to_update = [ |
|
159 | to_update = [ | |
158 | # FIXME - Disabled for now: we need to redo an automatic way |
|
160 | # FIXME - Disabled for now: we need to redo an automatic way | |
159 | # of generating the magic info inside the rst. |
|
161 | # of generating the magic info inside the rst. | |
160 | #('docs/magic.tex', |
|
162 | #('docs/magic.tex', | |
161 | #['IPython/Magic.py'], |
|
163 | #['IPython/Magic.py'], | |
162 | #"cd doc && ./update_magic.sh" ), |
|
164 | #"cd doc && ./update_magic.sh" ), | |
163 |
|
165 | |||
164 | ('docs/man/ipcluster.1.gz', |
|
166 | ('docs/man/ipcluster.1.gz', | |
165 | ['docs/man/ipcluster.1'], |
|
167 | ['docs/man/ipcluster.1'], | |
166 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
168 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), | |
167 |
|
169 | |||
168 | ('docs/man/ipcontroller.1.gz', |
|
170 | ('docs/man/ipcontroller.1.gz', | |
169 | ['docs/man/ipcontroller.1'], |
|
171 | ['docs/man/ipcontroller.1'], | |
170 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
172 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), | |
171 |
|
173 | |||
172 | ('docs/man/ipengine.1.gz', |
|
174 | ('docs/man/ipengine.1.gz', | |
173 | ['docs/man/ipengine.1'], |
|
175 | ['docs/man/ipengine.1'], | |
174 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
176 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), | |
175 |
|
177 | |||
176 | ('docs/man/iplogger.1.gz', |
|
178 | ('docs/man/iplogger.1.gz', | |
177 | ['docs/man/iplogger.1'], |
|
179 | ['docs/man/iplogger.1'], | |
178 | 'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'), |
|
180 | 'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'), | |
179 |
|
181 | |||
180 | ('docs/man/ipython.1.gz', |
|
182 | ('docs/man/ipython.1.gz', | |
181 | ['docs/man/ipython.1'], |
|
183 | ['docs/man/ipython.1'], | |
182 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
184 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), | |
183 |
|
185 | |||
184 | ('docs/man/irunner.1.gz', |
|
186 | ('docs/man/irunner.1.gz', | |
185 | ['docs/man/irunner.1'], |
|
187 | ['docs/man/irunner.1'], | |
186 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), |
|
188 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), | |
187 |
|
189 | |||
188 | ('docs/man/pycolor.1.gz', |
|
190 | ('docs/man/pycolor.1.gz', | |
189 | ['docs/man/pycolor.1'], |
|
191 | ['docs/man/pycolor.1'], | |
190 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), |
|
192 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), | |
191 | ] |
|
193 | ] | |
192 |
|
194 | |||
193 |
|
195 | |||
194 | [ target_update(*t) for t in to_update ] |
|
196 | [ target_update(*t) for t in to_update ] | |
195 |
|
197 | |||
196 | #--------------------------------------------------------------------------- |
|
198 | #--------------------------------------------------------------------------- | |
197 | # Find all the packages, package data, and data_files |
|
199 | # Find all the packages, package data, and data_files | |
198 | #--------------------------------------------------------------------------- |
|
200 | #--------------------------------------------------------------------------- | |
199 |
|
201 | |||
200 | packages = find_packages() |
|
202 | packages = find_packages() | |
201 | package_data = find_package_data() |
|
203 | package_data = find_package_data() | |
202 | data_files = find_data_files() |
|
204 | data_files = find_data_files() | |
203 |
|
205 | |||
204 | setup_args['packages'] = packages |
|
206 | setup_args['packages'] = packages | |
205 | setup_args['package_data'] = package_data |
|
207 | setup_args['package_data'] = package_data | |
206 | setup_args['data_files'] = data_files |
|
208 | setup_args['data_files'] = data_files | |
207 |
|
209 | |||
208 | #--------------------------------------------------------------------------- |
|
210 | #--------------------------------------------------------------------------- | |
209 | # custom distutils commands |
|
211 | # custom distutils commands | |
210 | #--------------------------------------------------------------------------- |
|
212 | #--------------------------------------------------------------------------- | |
211 | # imports here, so they are after setuptools import if there was one |
|
213 | # imports here, so they are after setuptools import if there was one | |
212 | from distutils.command.sdist import sdist |
|
214 | from distutils.command.sdist import sdist | |
213 | from distutils.command.upload import upload |
|
215 | from distutils.command.upload import upload | |
214 |
|
216 | |||
215 | class UploadWindowsInstallers(upload): |
|
217 | class UploadWindowsInstallers(upload): | |
216 |
|
218 | |||
217 | description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" |
|
219 | description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" | |
218 | user_options = upload.user_options + [ |
|
220 | user_options = upload.user_options + [ | |
219 | ('files=', 'f', 'exe file (or glob) to upload') |
|
221 | ('files=', 'f', 'exe file (or glob) to upload') | |
220 | ] |
|
222 | ] | |
221 | def initialize_options(self): |
|
223 | def initialize_options(self): | |
222 | upload.initialize_options(self) |
|
224 | upload.initialize_options(self) | |
223 | meta = self.distribution.metadata |
|
225 | meta = self.distribution.metadata | |
224 | base = '{name}-{version}'.format( |
|
226 | base = '{name}-{version}'.format( | |
225 | name=meta.get_name(), |
|
227 | name=meta.get_name(), | |
226 | version=meta.get_version() |
|
228 | version=meta.get_version() | |
227 | ) |
|
229 | ) | |
228 | self.files = os.path.join('dist', '%s.*.exe' % base) |
|
230 | self.files = os.path.join('dist', '%s.*.exe' % base) | |
229 |
|
231 | |||
230 | def run(self): |
|
232 | def run(self): | |
231 | for dist_file in glob(self.files): |
|
233 | for dist_file in glob(self.files): | |
232 | self.upload_file('bdist_wininst', 'any', dist_file) |
|
234 | self.upload_file('bdist_wininst', 'any', dist_file) | |
233 |
|
235 | |||
234 | setup_args['cmdclass'] = { |
|
236 | setup_args['cmdclass'] = { | |
235 | 'build_py': git_prebuild('IPython'), |
|
237 | 'build_py': git_prebuild('IPython'), | |
236 | 'sdist' : git_prebuild('IPython', sdist), |
|
238 | 'sdist' : git_prebuild('IPython', sdist), | |
237 | 'upload_wininst' : UploadWindowsInstallers, |
|
239 | 'upload_wininst' : UploadWindowsInstallers, | |
238 | 'submodule' : UpdateSubmodules, |
|
240 | 'submodule' : UpdateSubmodules, | |
239 | } |
|
241 | } | |
240 |
|
242 | |||
241 | #--------------------------------------------------------------------------- |
|
243 | #--------------------------------------------------------------------------- | |
242 | # Handle scripts, dependencies, and setuptools specific things |
|
244 | # Handle scripts, dependencies, and setuptools specific things | |
243 | #--------------------------------------------------------------------------- |
|
245 | #--------------------------------------------------------------------------- | |
244 |
|
246 | |||
245 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
247 | # For some commands, use setuptools. Note that we do NOT list install here! | |
246 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
248 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' | |
247 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', |
|
249 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', | |
248 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', |
|
250 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', | |
249 | 'egg_info', 'easy_install', 'upload', |
|
251 | 'egg_info', 'easy_install', 'upload', | |
250 | )) |
|
252 | )) | |
251 | if sys.platform == 'win32': |
|
253 | if sys.platform == 'win32': | |
252 | # Depend on setuptools for install on *Windows only* |
|
254 | # Depend on setuptools for install on *Windows only* | |
253 | # If we get script-installation working without setuptools, |
|
255 | # If we get script-installation working without setuptools, | |
254 | # then we can back off, but until then use it. |
|
256 | # then we can back off, but until then use it. | |
255 | # See Issue #369 on GitHub for more |
|
257 | # See Issue #369 on GitHub for more | |
256 | needs_setuptools.add('install') |
|
258 | needs_setuptools.add('install') | |
257 |
|
259 | |||
258 | if len(needs_setuptools.intersection(sys.argv)) > 0: |
|
260 | if len(needs_setuptools.intersection(sys.argv)) > 0: | |
259 | import setuptools |
|
261 | import setuptools | |
260 |
|
262 | |||
261 | # This dict is used for passing extra arguments that are setuptools |
|
263 | # This dict is used for passing extra arguments that are setuptools | |
262 | # specific to setup |
|
264 | # specific to setup | |
263 | setuptools_extra_args = {} |
|
265 | setuptools_extra_args = {} | |
264 |
|
266 | |||
265 | if 'setuptools' in sys.modules: |
|
267 | if 'setuptools' in sys.modules: | |
266 | # setup.py develop should check for submodules |
|
268 | # setup.py develop should check for submodules | |
267 | from setuptools.command.develop import develop |
|
269 | from setuptools.command.develop import develop | |
268 | setup_args['cmdclass']['develop'] = require_submodules(develop) |
|
270 | setup_args['cmdclass']['develop'] = require_submodules(develop) | |
269 |
|
271 | |||
270 | setuptools_extra_args['zip_safe'] = False |
|
272 | setuptools_extra_args['zip_safe'] = False | |
271 | setuptools_extra_args['entry_points'] = find_scripts(True) |
|
273 | setuptools_extra_args['entry_points'] = find_scripts(True) | |
272 | setup_args['extras_require'] = dict( |
|
274 | setup_args['extras_require'] = dict( | |
273 | parallel = 'pyzmq>=2.1.11', |
|
275 | parallel = 'pyzmq>=2.1.11', | |
274 | qtconsole = ['pyzmq>=2.1.11', 'pygments'], |
|
276 | qtconsole = ['pyzmq>=2.1.11', 'pygments'], | |
275 | zmq = 'pyzmq>=2.1.11', |
|
277 | zmq = 'pyzmq>=2.1.11', | |
276 | doc = 'Sphinx>=0.3', |
|
278 | doc = 'Sphinx>=0.3', | |
277 | test = 'nose>=0.10.1', |
|
279 | test = 'nose>=0.10.1', | |
278 | notebook = ['tornado>=2.0', 'pyzmq>=2.1.11', 'jinja2'], |
|
280 | notebook = ['tornado>=2.0', 'pyzmq>=2.1.11', 'jinja2'], | |
279 | ) |
|
281 | ) | |
280 | requires = setup_args.setdefault('install_requires', []) |
|
282 | requires = setup_args.setdefault('install_requires', []) | |
281 | setupext.display_status = False |
|
283 | setupext.display_status = False | |
282 | if not setupext.check_for_readline(): |
|
284 | if not setupext.check_for_readline(): | |
283 | if sys.platform == 'darwin': |
|
285 | if sys.platform == 'darwin': | |
284 | requires.append('readline') |
|
286 | requires.append('readline') | |
285 | elif sys.platform.startswith('win'): |
|
287 | elif sys.platform.startswith('win'): | |
286 | # Pyreadline 64 bit windows issue solved in versions >=1.7.1 |
|
288 | # Pyreadline 64 bit windows issue solved in versions >=1.7.1 | |
287 | # Also solves issues with some older versions of pyreadline that |
|
289 | # Also solves issues with some older versions of pyreadline that | |
288 | # satisfy the unconstrained depdendency. |
|
290 | # satisfy the unconstrained depdendency. | |
289 | requires.append('pyreadline>=1.7.1') |
|
291 | requires.append('pyreadline>=1.7.1') | |
290 | else: |
|
292 | else: | |
291 | pass |
|
293 | pass | |
292 | # do we want to install readline here? |
|
294 | # do we want to install readline here? | |
293 |
|
295 | |||
294 | # Script to be run by the windows binary installer after the default setup |
|
296 | # Script to be run by the windows binary installer after the default setup | |
295 | # routine, to add shortcuts and similar windows-only things. Windows |
|
297 | # routine, to add shortcuts and similar windows-only things. Windows | |
296 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
298 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils | |
297 | # doesn't find them. |
|
299 | # doesn't find them. | |
298 | if 'bdist_wininst' in sys.argv: |
|
300 | if 'bdist_wininst' in sys.argv: | |
299 | if len(sys.argv) > 2 and \ |
|
301 | if len(sys.argv) > 2 and \ | |
300 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
302 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): | |
301 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." |
|
303 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." | |
302 | sys.exit(1) |
|
304 | sys.exit(1) | |
303 | setup_args['data_files'].append( |
|
305 | setup_args['data_files'].append( | |
304 | ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')]) |
|
306 | ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')]) | |
305 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
307 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] | |
306 | setup_args['options'] = {"bdist_wininst": |
|
308 | setup_args['options'] = {"bdist_wininst": | |
307 | {"install_script": |
|
309 | {"install_script": | |
308 | "ipython_win_post_install.py"}} |
|
310 | "ipython_win_post_install.py"}} | |
309 |
|
311 | |||
310 | if PY3: |
|
312 | if PY3: | |
311 | setuptools_extra_args['use_2to3'] = True |
|
313 | setuptools_extra_args['use_2to3'] = True | |
312 | # we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code |
|
314 | # we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code | |
313 | # so we explicitly disable some 2to3 fixes to be sure we aren't forgetting |
|
315 | # so we explicitly disable some 2to3 fixes to be sure we aren't forgetting | |
314 | # anything. |
|
316 | # anything. | |
315 | setuptools_extra_args['use_2to3_exclude_fixers'] = [ |
|
317 | setuptools_extra_args['use_2to3_exclude_fixers'] = [ | |
316 | 'lib2to3.fixes.fix_apply', |
|
318 | 'lib2to3.fixes.fix_apply', | |
317 | 'lib2to3.fixes.fix_except', |
|
319 | 'lib2to3.fixes.fix_except', | |
318 | 'lib2to3.fixes.fix_has_key', |
|
320 | 'lib2to3.fixes.fix_has_key', | |
319 | 'lib2to3.fixes.fix_next', |
|
321 | 'lib2to3.fixes.fix_next', | |
320 | 'lib2to3.fixes.fix_repr', |
|
322 | 'lib2to3.fixes.fix_repr', | |
321 | 'lib2to3.fixes.fix_tuple_params', |
|
323 | 'lib2to3.fixes.fix_tuple_params', | |
322 | ] |
|
324 | ] | |
323 | from setuptools.command.build_py import build_py |
|
325 | from setuptools.command.build_py import build_py | |
324 | setup_args['cmdclass'] = {'build_py': git_prebuild('IPython', build_cmd=build_py)} |
|
326 | setup_args['cmdclass'] = {'build_py': git_prebuild('IPython', build_cmd=build_py)} | |
325 | setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3') |
|
327 | setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3') | |
326 | setuptools._dont_write_bytecode = True |
|
328 | setuptools._dont_write_bytecode = True | |
327 | else: |
|
329 | else: | |
328 | # If we are running without setuptools, call this function which will |
|
330 | # If we are running without setuptools, call this function which will | |
329 | # check for dependencies an inform the user what is needed. This is |
|
331 | # check for dependencies an inform the user what is needed. This is | |
330 | # just to make life easy for users. |
|
332 | # just to make life easy for users. | |
331 | check_for_dependencies() |
|
333 | check_for_dependencies() | |
332 | setup_args['scripts'] = find_scripts(False) |
|
334 | setup_args['scripts'] = find_scripts(False) | |
333 |
|
335 | |||
334 | #--------------------------------------------------------------------------- |
|
336 | #--------------------------------------------------------------------------- | |
335 | # Do the actual setup now |
|
337 | # Do the actual setup now | |
336 | #--------------------------------------------------------------------------- |
|
338 | #--------------------------------------------------------------------------- | |
337 |
|
339 | |||
338 | setup_args.update(setuptools_extra_args) |
|
340 | setup_args.update(setuptools_extra_args) | |
339 |
|
341 | |||
340 | def main(): |
|
342 | def main(): | |
341 | setup(**setup_args) |
|
343 | setup(**setup_args) | |
342 | cleanup() |
|
344 | cleanup() | |
343 |
|
345 | |||
344 | if __name__ == '__main__': |
|
346 | if __name__ == '__main__': | |
345 | main() |
|
347 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now