Show More
@@ -1,344 +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.rst, distributed with this software. |
|
17 | # The full license is in the file COPYING.rst, 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 | v = sys.version_info |
|
29 | v = sys.version_info | |
30 | if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)): |
|
30 | if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)): | |
31 | error = "ERROR: IPython requires Python version 2.7 or 3.3 or above." |
|
31 | error = "ERROR: IPython requires Python version 2.7 or 3.3 or above." | |
32 | print(error, file=sys.stderr) |
|
32 | print(error, file=sys.stderr) | |
33 | sys.exit(1) |
|
33 | sys.exit(1) | |
34 |
|
34 | |||
35 | PY3 = (sys.version_info[0] >= 3) |
|
35 | PY3 = (sys.version_info[0] >= 3) | |
36 |
|
36 | |||
37 | # At least we're on the python version we need, move on. |
|
37 | # At least we're on the python version we need, move on. | |
38 |
|
38 | |||
39 | #------------------------------------------------------------------------------- |
|
39 | #------------------------------------------------------------------------------- | |
40 | # Imports |
|
40 | # Imports | |
41 | #------------------------------------------------------------------------------- |
|
41 | #------------------------------------------------------------------------------- | |
42 |
|
42 | |||
43 | # Stdlib imports |
|
43 | # Stdlib imports | |
44 | import os |
|
44 | import os | |
45 | import shutil |
|
45 | import shutil | |
46 |
|
46 | |||
47 | from glob import glob |
|
47 | from glob import glob | |
48 |
|
48 | |||
49 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
49 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | |
50 | # update it when the contents of directories change. |
|
50 | # update it when the contents of directories change. | |
51 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
51 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') | |
52 |
|
52 | |||
53 | from distutils.core import setup |
|
53 | from distutils.core import setup | |
54 |
|
54 | |||
55 | # Our own imports |
|
55 | # Our own imports | |
56 | from setupbase import target_update |
|
56 | from setupbase import target_update | |
57 |
|
57 | |||
58 | from setupbase import ( |
|
58 | from setupbase import ( | |
59 | setup_args, |
|
59 | setup_args, | |
60 | find_packages, |
|
60 | find_packages, | |
61 | find_package_data, |
|
61 | find_package_data, | |
62 | check_package_data_first, |
|
62 | check_package_data_first, | |
63 | find_entry_points, |
|
63 | find_entry_points, | |
64 | build_scripts_entrypt, |
|
64 | build_scripts_entrypt, | |
65 | find_data_files, |
|
65 | find_data_files, | |
66 | check_for_dependencies, |
|
66 | check_for_dependencies, | |
67 | git_prebuild, |
|
67 | git_prebuild, | |
68 | check_submodule_status, |
|
68 | check_submodule_status, | |
69 | update_submodules, |
|
69 | update_submodules, | |
70 | require_submodules, |
|
70 | require_submodules, | |
71 | UpdateSubmodules, |
|
71 | UpdateSubmodules, | |
72 | get_bdist_wheel, |
|
72 | get_bdist_wheel, | |
73 | CompileCSS, |
|
73 | CompileCSS, | |
74 | JavascriptVersion, |
|
74 | JavascriptVersion, | |
75 | install_symlinked, |
|
75 | install_symlinked, | |
76 | install_lib_symlink, |
|
76 | install_lib_symlink, | |
77 | install_scripts_for_symlink, |
|
77 | install_scripts_for_symlink, | |
78 | unsymlink, |
|
78 | unsymlink, | |
79 | ) |
|
79 | ) | |
80 | from setupext import setupext |
|
80 | from setupext import setupext | |
81 |
|
81 | |||
82 | isfile = os.path.isfile |
|
82 | isfile = os.path.isfile | |
83 | pjoin = os.path.join |
|
83 | pjoin = os.path.join | |
84 |
|
84 | |||
85 | #----------------------------------------------------------------------------- |
|
85 | #----------------------------------------------------------------------------- | |
86 | # Function definitions |
|
86 | # Function definitions | |
87 | #----------------------------------------------------------------------------- |
|
87 | #----------------------------------------------------------------------------- | |
88 |
|
88 | |||
89 | def cleanup(): |
|
89 | def cleanup(): | |
90 | """Clean up the junk left around by the build process""" |
|
90 | """Clean up the junk left around by the build process""" | |
91 | if "develop" not in sys.argv and "egg_info" not in sys.argv: |
|
91 | if "develop" not in sys.argv and "egg_info" not in sys.argv: | |
92 | try: |
|
92 | try: | |
93 | shutil.rmtree('ipython.egg-info') |
|
93 | shutil.rmtree('ipython.egg-info') | |
94 | except: |
|
94 | except: | |
95 | try: |
|
95 | try: | |
96 | os.unlink('ipython.egg-info') |
|
96 | os.unlink('ipython.egg-info') | |
97 | except: |
|
97 | except: | |
98 | pass |
|
98 | pass | |
99 |
|
99 | |||
100 | #------------------------------------------------------------------------------- |
|
100 | #------------------------------------------------------------------------------- | |
101 | # Handle OS specific things |
|
101 | # Handle OS specific things | |
102 | #------------------------------------------------------------------------------- |
|
102 | #------------------------------------------------------------------------------- | |
103 |
|
103 | |||
104 | if os.name in ('nt','dos'): |
|
104 | if os.name in ('nt','dos'): | |
105 | os_name = 'windows' |
|
105 | os_name = 'windows' | |
106 | else: |
|
106 | else: | |
107 | os_name = os.name |
|
107 | os_name = os.name | |
108 |
|
108 | |||
109 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
109 | # Under Windows, 'sdist' has not been supported. Now that the docs build with | |
110 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
110 | # Sphinx it might work, but let's not turn it on until someone confirms that it | |
111 | # actually works. |
|
111 | # actually works. | |
112 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
112 | if os_name == 'windows' and 'sdist' in sys.argv: | |
113 | print('The sdist command is not available under Windows. Exiting.') |
|
113 | print('The sdist command is not available under Windows. Exiting.') | |
114 | sys.exit(1) |
|
114 | sys.exit(1) | |
115 |
|
115 | |||
116 | #------------------------------------------------------------------------------- |
|
116 | #------------------------------------------------------------------------------- | |
117 | # Make sure we aren't trying to run without submodules |
|
117 | # Make sure we aren't trying to run without submodules | |
118 | #------------------------------------------------------------------------------- |
|
118 | #------------------------------------------------------------------------------- | |
119 | here = os.path.abspath(os.path.dirname(__file__)) |
|
119 | here = os.path.abspath(os.path.dirname(__file__)) | |
120 |
|
120 | |||
121 | def require_clean_submodules(): |
|
121 | def require_clean_submodules(): | |
122 | """Check on git submodules before distutils can do anything |
|
122 | """Check on git submodules before distutils can do anything | |
123 |
|
123 | |||
124 | Since distutils cannot be trusted to update the tree |
|
124 | Since distutils cannot be trusted to update the tree | |
125 | after everything has been set in motion, |
|
125 | after everything has been set in motion, | |
126 | this is not a distutils command. |
|
126 | this is not a distutils command. | |
127 | """ |
|
127 | """ | |
128 | # PACKAGERS: Add a return here to skip checks for git submodules |
|
128 | # PACKAGERS: Add a return here to skip checks for git submodules | |
129 |
|
129 | |||
130 | # don't do anything if nothing is actually supposed to happen |
|
130 | # don't do anything if nothing is actually supposed to happen | |
131 | for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'): |
|
131 | for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'): | |
132 | if do_nothing in sys.argv: |
|
132 | if do_nothing in sys.argv: | |
133 | return |
|
133 | return | |
134 |
|
134 | |||
135 | status = check_submodule_status(here) |
|
135 | status = check_submodule_status(here) | |
136 |
|
136 | |||
137 | if status == "missing": |
|
137 | if status == "missing": | |
138 | print("checking out submodules for the first time") |
|
138 | print("checking out submodules for the first time") | |
139 | update_submodules(here) |
|
139 | update_submodules(here) | |
140 | elif status == "unclean": |
|
140 | elif status == "unclean": | |
141 | print('\n'.join([ |
|
141 | print('\n'.join([ | |
142 | "Cannot build / install IPython with unclean submodules", |
|
142 | "Cannot build / install IPython with unclean submodules", | |
143 | "Please update submodules with", |
|
143 | "Please update submodules with", | |
144 | " python setup.py submodule", |
|
144 | " python setup.py submodule", | |
145 | "or", |
|
145 | "or", | |
146 | " git submodule update", |
|
146 | " git submodule update", | |
147 | "or commit any submodule changes you have made." |
|
147 | "or commit any submodule changes you have made." | |
148 | ])) |
|
148 | ])) | |
149 | sys.exit(1) |
|
149 | sys.exit(1) | |
150 |
|
150 | |||
151 | require_clean_submodules() |
|
151 | require_clean_submodules() | |
152 |
|
152 | |||
153 | #------------------------------------------------------------------------------- |
|
153 | #------------------------------------------------------------------------------- | |
154 | # Things related to the IPython documentation |
|
154 | # Things related to the IPython documentation | |
155 | #------------------------------------------------------------------------------- |
|
155 | #------------------------------------------------------------------------------- | |
156 |
|
156 | |||
157 | # update the manuals when building a source dist |
|
157 | # update the manuals when building a source dist | |
158 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
158 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): | |
159 |
|
159 | |||
160 | # List of things to be updated. Each entry is a triplet of args for |
|
160 | # List of things to be updated. Each entry is a triplet of args for | |
161 | # target_update() |
|
161 | # target_update() | |
162 | to_update = [ |
|
162 | to_update = [ | |
163 | # FIXME - Disabled for now: we need to redo an automatic way |
|
163 | # FIXME - Disabled for now: we need to redo an automatic way | |
164 | # of generating the magic info inside the rst. |
|
164 | # of generating the magic info inside the rst. | |
165 | #('docs/magic.tex', |
|
165 | #('docs/magic.tex', | |
166 | #['IPython/Magic.py'], |
|
166 | #['IPython/Magic.py'], | |
167 | #"cd doc && ./update_magic.sh" ), |
|
167 | #"cd doc && ./update_magic.sh" ), | |
168 |
|
168 | |||
169 | ('docs/man/ipcluster.1.gz', |
|
169 | ('docs/man/ipcluster.1.gz', | |
170 | ['docs/man/ipcluster.1'], |
|
170 | ['docs/man/ipcluster.1'], | |
171 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
171 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), | |
172 |
|
172 | |||
173 | ('docs/man/ipcontroller.1.gz', |
|
173 | ('docs/man/ipcontroller.1.gz', | |
174 | ['docs/man/ipcontroller.1'], |
|
174 | ['docs/man/ipcontroller.1'], | |
175 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
175 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), | |
176 |
|
176 | |||
177 | ('docs/man/ipengine.1.gz', |
|
177 | ('docs/man/ipengine.1.gz', | |
178 | ['docs/man/ipengine.1'], |
|
178 | ['docs/man/ipengine.1'], | |
179 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
179 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), | |
180 |
|
180 | |||
181 | ('docs/man/ipython.1.gz', |
|
181 | ('docs/man/ipython.1.gz', | |
182 | ['docs/man/ipython.1'], |
|
182 | ['docs/man/ipython.1'], | |
183 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
183 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), | |
184 |
|
184 | |||
185 | ] |
|
185 | ] | |
186 |
|
186 | |||
187 |
|
187 | |||
188 | [ target_update(*t) for t in to_update ] |
|
188 | [ target_update(*t) for t in to_update ] | |
189 |
|
189 | |||
190 | #--------------------------------------------------------------------------- |
|
190 | #--------------------------------------------------------------------------- | |
191 | # Find all the packages, package data, and data_files |
|
191 | # Find all the packages, package data, and data_files | |
192 | #--------------------------------------------------------------------------- |
|
192 | #--------------------------------------------------------------------------- | |
193 |
|
193 | |||
194 | packages = find_packages() |
|
194 | packages = find_packages() | |
195 | package_data = find_package_data() |
|
195 | package_data = find_package_data() | |
196 |
|
196 | |||
197 | data_files = find_data_files() |
|
197 | data_files = find_data_files() | |
198 |
|
198 | |||
199 | setup_args['packages'] = packages |
|
199 | setup_args['packages'] = packages | |
200 | setup_args['package_data'] = package_data |
|
200 | setup_args['package_data'] = package_data | |
201 | setup_args['data_files'] = data_files |
|
201 | setup_args['data_files'] = data_files | |
202 |
|
202 | |||
203 | #--------------------------------------------------------------------------- |
|
203 | #--------------------------------------------------------------------------- | |
204 | # custom distutils commands |
|
204 | # custom distutils commands | |
205 | #--------------------------------------------------------------------------- |
|
205 | #--------------------------------------------------------------------------- | |
206 | # imports here, so they are after setuptools import if there was one |
|
206 | # imports here, so they are after setuptools import if there was one | |
207 | from distutils.command.sdist import sdist |
|
207 | from distutils.command.sdist import sdist | |
208 | from distutils.command.upload import upload |
|
208 | from distutils.command.upload import upload | |
209 |
|
209 | |||
210 | class UploadWindowsInstallers(upload): |
|
210 | class UploadWindowsInstallers(upload): | |
211 |
|
211 | |||
212 | description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" |
|
212 | description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" | |
213 | user_options = upload.user_options + [ |
|
213 | user_options = upload.user_options + [ | |
214 | ('files=', 'f', 'exe file (or glob) to upload') |
|
214 | ('files=', 'f', 'exe file (or glob) to upload') | |
215 | ] |
|
215 | ] | |
216 | def initialize_options(self): |
|
216 | def initialize_options(self): | |
217 | upload.initialize_options(self) |
|
217 | upload.initialize_options(self) | |
218 | meta = self.distribution.metadata |
|
218 | meta = self.distribution.metadata | |
219 | base = '{name}-{version}'.format( |
|
219 | base = '{name}-{version}'.format( | |
220 | name=meta.get_name(), |
|
220 | name=meta.get_name(), | |
221 | version=meta.get_version() |
|
221 | version=meta.get_version() | |
222 | ) |
|
222 | ) | |
223 | self.files = os.path.join('dist', '%s.*.exe' % base) |
|
223 | self.files = os.path.join('dist', '%s.*.exe' % base) | |
224 |
|
224 | |||
225 | def run(self): |
|
225 | def run(self): | |
226 | for dist_file in glob(self.files): |
|
226 | for dist_file in glob(self.files): | |
227 | self.upload_file('bdist_wininst', 'any', dist_file) |
|
227 | self.upload_file('bdist_wininst', 'any', dist_file) | |
228 |
|
228 | |||
229 | setup_args['cmdclass'] = { |
|
229 | setup_args['cmdclass'] = { | |
230 | 'build_py': check_package_data_first(git_prebuild('IPython')), |
|
230 | 'build_py': check_package_data_first(git_prebuild('IPython')), | |
231 | 'sdist' : git_prebuild('IPython', sdist), |
|
231 | 'sdist' : git_prebuild('IPython', sdist), | |
232 | 'upload_wininst' : UploadWindowsInstallers, |
|
232 | 'upload_wininst' : UploadWindowsInstallers, | |
233 | 'submodule' : UpdateSubmodules, |
|
233 | 'submodule' : UpdateSubmodules, | |
234 | 'css' : CompileCSS, |
|
234 | 'css' : CompileCSS, | |
235 | 'symlink': install_symlinked, |
|
235 | 'symlink': install_symlinked, | |
236 | 'install_lib_symlink': install_lib_symlink, |
|
236 | 'install_lib_symlink': install_lib_symlink, | |
237 | 'install_scripts_sym': install_scripts_for_symlink, |
|
237 | 'install_scripts_sym': install_scripts_for_symlink, | |
238 | 'unsymlink': unsymlink, |
|
238 | 'unsymlink': unsymlink, | |
239 | 'jsversion' : JavascriptVersion, |
|
239 | 'jsversion' : JavascriptVersion, | |
240 | } |
|
240 | } | |
241 |
|
241 | |||
242 | #--------------------------------------------------------------------------- |
|
242 | #--------------------------------------------------------------------------- | |
243 | # Handle scripts, dependencies, and setuptools specific things |
|
243 | # Handle scripts, dependencies, and setuptools specific things | |
244 | #--------------------------------------------------------------------------- |
|
244 | #--------------------------------------------------------------------------- | |
245 |
|
245 | |||
246 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
246 | # For some commands, use setuptools. Note that we do NOT list install here! | |
247 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
247 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' | |
248 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', |
|
248 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', | |
249 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel', |
|
249 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel', | |
250 | 'egg_info', 'easy_install', 'upload', 'install_egg_info', |
|
250 | 'egg_info', 'easy_install', 'upload', 'install_egg_info', | |
251 | )) |
|
251 | )) | |
252 | if sys.platform == 'win32': |
|
252 | if sys.platform == 'win32': | |
253 | # Depend on setuptools for install on *Windows only* |
|
253 | # Depend on setuptools for install on *Windows only* | |
254 | # If we get script-installation working without setuptools, |
|
254 | # If we get script-installation working without setuptools, | |
255 | # then we can back off, but until then use it. |
|
255 | # then we can back off, but until then use it. | |
256 | # See Issue #369 on GitHub for more |
|
256 | # See Issue #369 on GitHub for more | |
257 | needs_setuptools.add('install') |
|
257 | needs_setuptools.add('install') | |
258 |
|
258 | |||
259 | if len(needs_setuptools.intersection(sys.argv)) > 0: |
|
259 | if len(needs_setuptools.intersection(sys.argv)) > 0: | |
260 | import setuptools |
|
260 | import setuptools | |
261 |
|
261 | |||
262 | # This dict is used for passing extra arguments that are setuptools |
|
262 | # This dict is used for passing extra arguments that are setuptools | |
263 | # specific to setup |
|
263 | # specific to setup | |
264 | setuptools_extra_args = {} |
|
264 | setuptools_extra_args = {} | |
265 |
|
265 | |||
266 | # setuptools requirements |
|
266 | # setuptools requirements | |
267 |
|
267 | |||
268 | extras_require = dict( |
|
268 | extras_require = dict( | |
269 | parallel = ['pyzmq>=2.1.11'], |
|
269 | parallel = ['pyzmq>=2.1.11'], | |
270 | qtconsole = ['pyzmq>=2.1.11', 'pygments'], |
|
270 | qtconsole = ['pyzmq>=2.1.11', 'pygments'], | |
271 | zmq = ['pyzmq>=2.1.11'], |
|
271 | zmq = ['pyzmq>=2.1.11'], | |
272 | doc = ['Sphinx>=1.1', 'numpydoc'], |
|
272 | doc = ['Sphinx>=1.1', 'numpydoc'], | |
273 | test = ['nose>=0.10.1'], |
|
273 | test = ['nose>=0.10.1'], | |
|
274 | terminal = [], | |||
274 | notebook = ['tornado>=3.1', 'pyzmq>=2.1.11', 'jinja2'], |
|
275 | notebook = ['tornado>=3.1', 'pyzmq>=2.1.11', 'jinja2'], | |
275 | nbconvert = ['pygments', 'jinja2', 'Sphinx>=0.3'] |
|
276 | nbconvert = ['pygments', 'jinja2', 'Sphinx>=0.3'] | |
276 | ) |
|
277 | ) | |
277 | if sys.version_info < (3, 3): |
|
278 | if sys.version_info < (3, 3): | |
278 | extras_require['test'].append('mock') |
|
279 | extras_require['test'].append('mock') | |
279 |
|
280 | |||
280 | everything = set() |
|
281 | everything = set() | |
281 | for deps in extras_require.values(): |
|
282 | for deps in extras_require.values(): | |
282 | everything.update(deps) |
|
283 | everything.update(deps) | |
283 | extras_require['all'] = everything |
|
284 | extras_require['all'] = everything | |
284 |
|
285 | |||
285 | install_requires = [] |
|
286 | install_requires = [] | |
|
287 | ||||
|
288 | # add readline | |||
286 | if sys.platform == 'darwin': |
|
289 | if sys.platform == 'darwin': | |
287 | if any(arg.startswith('bdist') for arg in sys.argv) or not setupext.check_for_readline(): |
|
290 | if any(arg.startswith('bdist') for arg in sys.argv) or not setupext.check_for_readline(): | |
288 | install_requires.append('gnureadline') |
|
291 | install_requires.append('gnureadline') | |
289 | elif sys.platform.startswith('win'): |
|
292 | elif sys.platform.startswith('win'): | |
290 | # Pyreadline has unicode and Python 3 fixes in 2.0 |
|
293 | extras_require['terminal'].append('pyreadline>=2.0') | |
291 | install_requires.append('pyreadline>=2.0') |
|
294 | ||
292 |
|
295 | |||
293 | if 'setuptools' in sys.modules: |
|
296 | if 'setuptools' in sys.modules: | |
294 | # setup.py develop should check for submodules |
|
297 | # setup.py develop should check for submodules | |
295 | from setuptools.command.develop import develop |
|
298 | from setuptools.command.develop import develop | |
296 | setup_args['cmdclass']['develop'] = require_submodules(develop) |
|
299 | setup_args['cmdclass']['develop'] = require_submodules(develop) | |
297 | setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel() |
|
300 | setup_args['cmdclass']['bdist_wheel'] = get_bdist_wheel() | |
298 |
|
301 | |||
299 | setuptools_extra_args['zip_safe'] = False |
|
302 | setuptools_extra_args['zip_safe'] = False | |
300 | setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()} |
|
303 | setuptools_extra_args['entry_points'] = {'console_scripts':find_entry_points()} | |
301 | setup_args['extras_require'] = extras_require |
|
304 | setup_args['extras_require'] = extras_require | |
302 | requires = setup_args['install_requires'] = install_requires |
|
305 | requires = setup_args['install_requires'] = install_requires | |
303 |
|
306 | |||
304 | # Script to be run by the windows binary installer after the default setup |
|
307 | # Script to be run by the windows binary installer after the default setup | |
305 | # routine, to add shortcuts and similar windows-only things. Windows |
|
308 | # routine, to add shortcuts and similar windows-only things. Windows | |
306 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
309 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils | |
307 | # doesn't find them. |
|
310 | # doesn't find them. | |
308 | if 'bdist_wininst' in sys.argv: |
|
311 | if 'bdist_wininst' in sys.argv: | |
309 | if len(sys.argv) > 2 and \ |
|
312 | if len(sys.argv) > 2 and \ | |
310 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
313 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): | |
311 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." |
|
314 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." | |
312 | sys.exit(1) |
|
315 | sys.exit(1) | |
313 | setup_args['data_files'].append( |
|
316 | setup_args['data_files'].append( | |
314 | ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')]) |
|
317 | ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')]) | |
315 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
318 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] | |
316 | setup_args['options'] = {"bdist_wininst": |
|
319 | setup_args['options'] = {"bdist_wininst": | |
317 | {"install_script": |
|
320 | {"install_script": | |
318 | "ipython_win_post_install.py"}} |
|
321 | "ipython_win_post_install.py"}} | |
319 |
|
322 | |||
320 | else: |
|
323 | else: | |
321 | # If we are installing without setuptools, call this function which will |
|
324 | # If we are installing without setuptools, call this function which will | |
322 | # check for dependencies an inform the user what is needed. This is |
|
325 | # check for dependencies an inform the user what is needed. This is | |
323 | # just to make life easy for users. |
|
326 | # just to make life easy for users. | |
324 | for install_cmd in ('install', 'symlink'): |
|
327 | for install_cmd in ('install', 'symlink'): | |
325 | if install_cmd in sys.argv: |
|
328 | if install_cmd in sys.argv: | |
326 | check_for_dependencies() |
|
329 | check_for_dependencies() | |
327 | break |
|
330 | break | |
328 | # scripts has to be a non-empty list, or install_scripts isn't called |
|
331 | # scripts has to be a non-empty list, or install_scripts isn't called | |
329 | setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()] |
|
332 | setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()] | |
330 |
|
333 | |||
331 | setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt |
|
334 | setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt | |
332 |
|
335 | |||
333 | #--------------------------------------------------------------------------- |
|
336 | #--------------------------------------------------------------------------- | |
334 | # Do the actual setup now |
|
337 | # Do the actual setup now | |
335 | #--------------------------------------------------------------------------- |
|
338 | #--------------------------------------------------------------------------- | |
336 |
|
339 | |||
337 | setup_args.update(setuptools_extra_args) |
|
340 | setup_args.update(setuptools_extra_args) | |
338 |
|
341 | |||
339 | def main(): |
|
342 | def main(): | |
340 | setup(**setup_args) |
|
343 | setup(**setup_args) | |
341 | cleanup() |
|
344 | cleanup() | |
342 |
|
345 | |||
343 | if __name__ == '__main__': |
|
346 | if __name__ == '__main__': | |
344 | main() |
|
347 | main() |
@@ -1,701 +1,696 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | """ |
|
2 | """ | |
3 | This module defines the things that are used in setup.py for building IPython |
|
3 | This module defines the things that are used in setup.py for building IPython | |
4 |
|
4 | |||
5 | This includes: |
|
5 | This includes: | |
6 |
|
6 | |||
7 | * The basic arguments to setup |
|
7 | * The basic arguments to setup | |
8 | * Functions for finding things like packages, package data, etc. |
|
8 | * Functions for finding things like packages, package data, etc. | |
9 | * A function for checking dependencies. |
|
9 | * A function for checking dependencies. | |
10 | """ |
|
10 | """ | |
11 | from __future__ import print_function |
|
|||
12 |
|
11 | |||
13 | #------------------------------------------------------------------------------- |
|
12 | # Copyright (c) IPython Development Team. | |
14 | # Copyright (C) 2008 The IPython Development Team |
|
13 | # Distributed under the terms of the Modified BSD License. | |
15 | # |
|
14 | ||
16 | # Distributed under the terms of the BSD License. The full license is in |
|
15 | from __future__ import print_function | |
17 | # the file COPYING, distributed as part of this software. |
|
|||
18 | #------------------------------------------------------------------------------- |
|
|||
19 |
|
16 | |||
20 | #------------------------------------------------------------------------------- |
|
|||
21 | # Imports |
|
|||
22 | #------------------------------------------------------------------------------- |
|
|||
23 | import errno |
|
17 | import errno | |
24 | import os |
|
18 | import os | |
25 | import sys |
|
19 | import sys | |
26 |
|
20 | |||
27 | from distutils.command.build_py import build_py |
|
21 | from distutils.command.build_py import build_py | |
28 | from distutils.command.build_scripts import build_scripts |
|
22 | from distutils.command.build_scripts import build_scripts | |
29 | from distutils.command.install import install |
|
23 | from distutils.command.install import install | |
30 | from distutils.command.install_scripts import install_scripts |
|
24 | from distutils.command.install_scripts import install_scripts | |
31 | from distutils.cmd import Command |
|
25 | from distutils.cmd import Command | |
32 | from fnmatch import fnmatch |
|
26 | from fnmatch import fnmatch | |
33 | from glob import glob |
|
27 | from glob import glob | |
34 | from subprocess import call |
|
28 | from subprocess import call | |
35 |
|
29 | |||
36 | from setupext import install_data_ext |
|
30 | from setupext import install_data_ext | |
37 |
|
31 | |||
38 | #------------------------------------------------------------------------------- |
|
32 | #------------------------------------------------------------------------------- | |
39 | # Useful globals and utility functions |
|
33 | # Useful globals and utility functions | |
40 | #------------------------------------------------------------------------------- |
|
34 | #------------------------------------------------------------------------------- | |
41 |
|
35 | |||
42 | # A few handy globals |
|
36 | # A few handy globals | |
43 | isfile = os.path.isfile |
|
37 | isfile = os.path.isfile | |
44 | pjoin = os.path.join |
|
38 | pjoin = os.path.join | |
45 | repo_root = os.path.dirname(os.path.abspath(__file__)) |
|
39 | repo_root = os.path.dirname(os.path.abspath(__file__)) | |
46 |
|
40 | |||
47 | def oscmd(s): |
|
41 | def oscmd(s): | |
48 | print(">", s) |
|
42 | print(">", s) | |
49 | os.system(s) |
|
43 | os.system(s) | |
50 |
|
44 | |||
51 | # Py3 compatibility hacks, without assuming IPython itself is installed with |
|
45 | # Py3 compatibility hacks, without assuming IPython itself is installed with | |
52 | # the full py3compat machinery. |
|
46 | # the full py3compat machinery. | |
53 |
|
47 | |||
54 | try: |
|
48 | try: | |
55 | execfile |
|
49 | execfile | |
56 | except NameError: |
|
50 | except NameError: | |
57 | def execfile(fname, globs, locs=None): |
|
51 | def execfile(fname, globs, locs=None): | |
58 | locs = locs or globs |
|
52 | locs = locs or globs | |
59 | exec(compile(open(fname).read(), fname, "exec"), globs, locs) |
|
53 | exec(compile(open(fname).read(), fname, "exec"), globs, locs) | |
60 |
|
54 | |||
61 | # A little utility we'll need below, since glob() does NOT allow you to do |
|
55 | # A little utility we'll need below, since glob() does NOT allow you to do | |
62 | # exclusion on multiple endings! |
|
56 | # exclusion on multiple endings! | |
63 | def file_doesnt_endwith(test,endings): |
|
57 | def file_doesnt_endwith(test,endings): | |
64 | """Return true if test is a file and its name does NOT end with any |
|
58 | """Return true if test is a file and its name does NOT end with any | |
65 | of the strings listed in endings.""" |
|
59 | of the strings listed in endings.""" | |
66 | if not isfile(test): |
|
60 | if not isfile(test): | |
67 | return False |
|
61 | return False | |
68 | for e in endings: |
|
62 | for e in endings: | |
69 | if test.endswith(e): |
|
63 | if test.endswith(e): | |
70 | return False |
|
64 | return False | |
71 | return True |
|
65 | return True | |
72 |
|
66 | |||
73 | #--------------------------------------------------------------------------- |
|
67 | #--------------------------------------------------------------------------- | |
74 | # Basic project information |
|
68 | # Basic project information | |
75 | #--------------------------------------------------------------------------- |
|
69 | #--------------------------------------------------------------------------- | |
76 |
|
70 | |||
77 | # release.py contains version, authors, license, url, keywords, etc. |
|
71 | # release.py contains version, authors, license, url, keywords, etc. | |
78 | execfile(pjoin(repo_root, 'IPython','core','release.py'), globals()) |
|
72 | execfile(pjoin(repo_root, 'IPython','core','release.py'), globals()) | |
79 |
|
73 | |||
80 | # Create a dict with the basic information |
|
74 | # Create a dict with the basic information | |
81 | # This dict is eventually passed to setup after additional keys are added. |
|
75 | # This dict is eventually passed to setup after additional keys are added. | |
82 | setup_args = dict( |
|
76 | setup_args = dict( | |
83 | name = name, |
|
77 | name = name, | |
84 | version = version, |
|
78 | version = version, | |
85 | description = description, |
|
79 | description = description, | |
86 | long_description = long_description, |
|
80 | long_description = long_description, | |
87 | author = author, |
|
81 | author = author, | |
88 | author_email = author_email, |
|
82 | author_email = author_email, | |
89 | url = url, |
|
83 | url = url, | |
90 | download_url = download_url, |
|
84 | download_url = download_url, | |
91 | license = license, |
|
85 | license = license, | |
92 | platforms = platforms, |
|
86 | platforms = platforms, | |
93 | keywords = keywords, |
|
87 | keywords = keywords, | |
94 | classifiers = classifiers, |
|
88 | classifiers = classifiers, | |
95 | cmdclass = {'install_data': install_data_ext}, |
|
89 | cmdclass = {'install_data': install_data_ext}, | |
96 | ) |
|
90 | ) | |
97 |
|
91 | |||
98 |
|
92 | |||
99 | #--------------------------------------------------------------------------- |
|
93 | #--------------------------------------------------------------------------- | |
100 | # Find packages |
|
94 | # Find packages | |
101 | #--------------------------------------------------------------------------- |
|
95 | #--------------------------------------------------------------------------- | |
102 |
|
96 | |||
103 | def find_packages(): |
|
97 | def find_packages(): | |
104 | """ |
|
98 | """ | |
105 | Find all of IPython's packages. |
|
99 | Find all of IPython's packages. | |
106 | """ |
|
100 | """ | |
107 | excludes = ['deathrow', 'quarantine'] |
|
101 | excludes = ['deathrow', 'quarantine'] | |
108 | packages = [] |
|
102 | packages = [] | |
109 | for dir,subdirs,files in os.walk('IPython'): |
|
103 | for dir,subdirs,files in os.walk('IPython'): | |
110 | package = dir.replace(os.path.sep, '.') |
|
104 | package = dir.replace(os.path.sep, '.') | |
111 | if any(package.startswith('IPython.'+exc) for exc in excludes): |
|
105 | if any(package.startswith('IPython.'+exc) for exc in excludes): | |
112 | # package is to be excluded (e.g. deathrow) |
|
106 | # package is to be excluded (e.g. deathrow) | |
113 | continue |
|
107 | continue | |
114 | if '__init__.py' not in files: |
|
108 | if '__init__.py' not in files: | |
115 | # not a package |
|
109 | # not a package | |
116 | continue |
|
110 | continue | |
117 | packages.append(package) |
|
111 | packages.append(package) | |
118 | return packages |
|
112 | return packages | |
119 |
|
113 | |||
120 | #--------------------------------------------------------------------------- |
|
114 | #--------------------------------------------------------------------------- | |
121 | # Find package data |
|
115 | # Find package data | |
122 | #--------------------------------------------------------------------------- |
|
116 | #--------------------------------------------------------------------------- | |
123 |
|
117 | |||
124 | def find_package_data(): |
|
118 | def find_package_data(): | |
125 | """ |
|
119 | """ | |
126 | Find IPython's package_data. |
|
120 | Find IPython's package_data. | |
127 | """ |
|
121 | """ | |
128 | # This is not enough for these things to appear in an sdist. |
|
122 | # This is not enough for these things to appear in an sdist. | |
129 | # We need to muck with the MANIFEST to get this to work |
|
123 | # We need to muck with the MANIFEST to get this to work | |
130 |
|
124 | |||
131 | # exclude components and less from the walk; |
|
125 | # exclude components and less from the walk; | |
132 | # we will build the components separately |
|
126 | # we will build the components separately | |
133 | excludes = [ |
|
127 | excludes = [ | |
134 | pjoin('static', 'components'), |
|
128 | pjoin('static', 'components'), | |
135 | pjoin('static', '*', 'less'), |
|
129 | pjoin('static', '*', 'less'), | |
136 | ] |
|
130 | ] | |
137 |
|
131 | |||
138 | # walk notebook resources: |
|
132 | # walk notebook resources: | |
139 | cwd = os.getcwd() |
|
133 | cwd = os.getcwd() | |
140 | os.chdir(os.path.join('IPython', 'html')) |
|
134 | os.chdir(os.path.join('IPython', 'html')) | |
141 | static_data = [] |
|
135 | static_data = [] | |
142 | for parent, dirs, files in os.walk('static'): |
|
136 | for parent, dirs, files in os.walk('static'): | |
143 | if any(fnmatch(parent, pat) for pat in excludes): |
|
137 | if any(fnmatch(parent, pat) for pat in excludes): | |
144 | # prevent descending into subdirs |
|
138 | # prevent descending into subdirs | |
145 | dirs[:] = [] |
|
139 | dirs[:] = [] | |
146 | continue |
|
140 | continue | |
147 | for f in files: |
|
141 | for f in files: | |
148 | static_data.append(pjoin(parent, f)) |
|
142 | static_data.append(pjoin(parent, f)) | |
149 |
|
143 | |||
150 | components = pjoin("static", "components") |
|
144 | components = pjoin("static", "components") | |
151 | # select the components we actually need to install |
|
145 | # select the components we actually need to install | |
152 | # (there are lots of resources we bundle for sdist-reasons that we don't actually use) |
|
146 | # (there are lots of resources we bundle for sdist-reasons that we don't actually use) | |
153 | static_data.extend([ |
|
147 | static_data.extend([ | |
154 | pjoin(components, "backbone", "backbone-min.js"), |
|
148 | pjoin(components, "backbone", "backbone-min.js"), | |
155 | pjoin(components, "bootstrap", "bootstrap", "js", "bootstrap.min.js"), |
|
149 | pjoin(components, "bootstrap", "bootstrap", "js", "bootstrap.min.js"), | |
156 | pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"), |
|
150 | pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"), | |
157 | pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"), |
|
151 | pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"), | |
158 | pjoin(components, "font-awesome", "font", "*.*"), |
|
152 | pjoin(components, "font-awesome", "font", "*.*"), | |
159 | pjoin(components, "google-caja", "html-css-sanitizer-minified.js"), |
|
153 | pjoin(components, "google-caja", "html-css-sanitizer-minified.js"), | |
160 | pjoin(components, "highlight.js", "build", "highlight.pack.js"), |
|
154 | pjoin(components, "highlight.js", "build", "highlight.pack.js"), | |
161 | pjoin(components, "jquery", "jquery.min.js"), |
|
155 | pjoin(components, "jquery", "jquery.min.js"), | |
162 | pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"), |
|
156 | pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"), | |
163 | pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"), |
|
157 | pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"), | |
164 | pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"), |
|
158 | pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"), | |
165 | pjoin(components, "marked", "lib", "marked.js"), |
|
159 | pjoin(components, "marked", "lib", "marked.js"), | |
166 | pjoin(components, "requirejs", "require.js"), |
|
160 | pjoin(components, "requirejs", "require.js"), | |
167 | pjoin(components, "underscore", "underscore-min.js"), |
|
161 | pjoin(components, "underscore", "underscore-min.js"), | |
168 | ]) |
|
162 | ]) | |
169 |
|
163 | |||
170 | # Ship all of Codemirror's CSS and JS |
|
164 | # Ship all of Codemirror's CSS and JS | |
171 | for parent, dirs, files in os.walk(pjoin(components, 'codemirror')): |
|
165 | for parent, dirs, files in os.walk(pjoin(components, 'codemirror')): | |
172 | for f in files: |
|
166 | for f in files: | |
173 | if f.endswith(('.js', '.css')): |
|
167 | if f.endswith(('.js', '.css')): | |
174 | static_data.append(pjoin(parent, f)) |
|
168 | static_data.append(pjoin(parent, f)) | |
175 |
|
169 | |||
176 | os.chdir(os.path.join('tests',)) |
|
170 | os.chdir(os.path.join('tests',)) | |
177 | js_tests = glob('*.js') + glob('*/*.js') |
|
171 | js_tests = glob('*.js') + glob('*/*.js') | |
178 |
|
172 | |||
179 | os.chdir(os.path.join(cwd, 'IPython', 'nbconvert')) |
|
173 | os.chdir(os.path.join(cwd, 'IPython', 'nbconvert')) | |
180 | nbconvert_templates = [os.path.join(dirpath, '*.*') |
|
174 | nbconvert_templates = [os.path.join(dirpath, '*.*') | |
181 | for dirpath, _, _ in os.walk('templates')] |
|
175 | for dirpath, _, _ in os.walk('templates')] | |
182 |
|
176 | |||
183 | os.chdir(cwd) |
|
177 | os.chdir(cwd) | |
184 |
|
178 | |||
185 | package_data = { |
|
179 | package_data = { | |
186 | 'IPython.config.profile' : ['README*', '*/*.py'], |
|
180 | 'IPython.config.profile' : ['README*', '*/*.py'], | |
187 | 'IPython.core.tests' : ['*.png', '*.jpg'], |
|
181 | 'IPython.core.tests' : ['*.png', '*.jpg'], | |
188 | 'IPython.lib.tests' : ['*.wav'], |
|
182 | 'IPython.lib.tests' : ['*.wav'], | |
189 | 'IPython.testing.plugin' : ['*.txt'], |
|
183 | 'IPython.testing.plugin' : ['*.txt'], | |
190 | 'IPython.html' : ['templates/*'] + static_data, |
|
184 | 'IPython.html' : ['templates/*'] + static_data, | |
191 | 'IPython.html.tests' : js_tests, |
|
185 | 'IPython.html.tests' : js_tests, | |
192 | 'IPython.qt.console' : ['resources/icon/*.svg'], |
|
186 | 'IPython.qt.console' : ['resources/icon/*.svg'], | |
193 | 'IPython.nbconvert' : nbconvert_templates + |
|
187 | 'IPython.nbconvert' : nbconvert_templates + | |
194 | ['tests/files/*.*', 'exporters/tests/files/*.*'], |
|
188 | ['tests/files/*.*', 'exporters/tests/files/*.*'], | |
195 | 'IPython.nbconvert.filters' : ['marked.js'], |
|
189 | 'IPython.nbconvert.filters' : ['marked.js'], | |
196 | 'IPython.nbformat' : ['tests/*.ipynb'] |
|
190 | 'IPython.nbformat' : ['tests/*.ipynb'] | |
197 | } |
|
191 | } | |
198 |
|
192 | |||
199 | return package_data |
|
193 | return package_data | |
200 |
|
194 | |||
201 |
|
195 | |||
202 | def check_package_data(package_data): |
|
196 | def check_package_data(package_data): | |
203 | """verify that package_data globs make sense""" |
|
197 | """verify that package_data globs make sense""" | |
204 | print("checking package data") |
|
198 | print("checking package data") | |
205 | for pkg, data in package_data.items(): |
|
199 | for pkg, data in package_data.items(): | |
206 | pkg_root = pjoin(*pkg.split('.')) |
|
200 | pkg_root = pjoin(*pkg.split('.')) | |
207 | for d in data: |
|
201 | for d in data: | |
208 | path = pjoin(pkg_root, d) |
|
202 | path = pjoin(pkg_root, d) | |
209 | if '*' in path: |
|
203 | if '*' in path: | |
210 | assert len(glob(path)) > 0, "No files match pattern %s" % path |
|
204 | assert len(glob(path)) > 0, "No files match pattern %s" % path | |
211 | else: |
|
205 | else: | |
212 | assert os.path.exists(path), "Missing package data: %s" % path |
|
206 | assert os.path.exists(path), "Missing package data: %s" % path | |
213 |
|
207 | |||
214 |
|
208 | |||
215 | def check_package_data_first(command): |
|
209 | def check_package_data_first(command): | |
216 | """decorator for checking package_data before running a given command |
|
210 | """decorator for checking package_data before running a given command | |
217 |
|
211 | |||
218 | Probably only needs to wrap build_py |
|
212 | Probably only needs to wrap build_py | |
219 | """ |
|
213 | """ | |
220 | class DecoratedCommand(command): |
|
214 | class DecoratedCommand(command): | |
221 | def run(self): |
|
215 | def run(self): | |
222 | check_package_data(self.package_data) |
|
216 | check_package_data(self.package_data) | |
223 | command.run(self) |
|
217 | command.run(self) | |
224 | return DecoratedCommand |
|
218 | return DecoratedCommand | |
225 |
|
219 | |||
226 |
|
220 | |||
227 | #--------------------------------------------------------------------------- |
|
221 | #--------------------------------------------------------------------------- | |
228 | # Find data files |
|
222 | # Find data files | |
229 | #--------------------------------------------------------------------------- |
|
223 | #--------------------------------------------------------------------------- | |
230 |
|
224 | |||
231 | def make_dir_struct(tag,base,out_base): |
|
225 | def make_dir_struct(tag,base,out_base): | |
232 | """Make the directory structure of all files below a starting dir. |
|
226 | """Make the directory structure of all files below a starting dir. | |
233 |
|
227 | |||
234 | This is just a convenience routine to help build a nested directory |
|
228 | This is just a convenience routine to help build a nested directory | |
235 | hierarchy because distutils is too stupid to do this by itself. |
|
229 | hierarchy because distutils is too stupid to do this by itself. | |
236 |
|
230 | |||
237 | XXX - this needs a proper docstring! |
|
231 | XXX - this needs a proper docstring! | |
238 | """ |
|
232 | """ | |
239 |
|
233 | |||
240 | # we'll use these a lot below |
|
234 | # we'll use these a lot below | |
241 | lbase = len(base) |
|
235 | lbase = len(base) | |
242 | pathsep = os.path.sep |
|
236 | pathsep = os.path.sep | |
243 | lpathsep = len(pathsep) |
|
237 | lpathsep = len(pathsep) | |
244 |
|
238 | |||
245 | out = [] |
|
239 | out = [] | |
246 | for (dirpath,dirnames,filenames) in os.walk(base): |
|
240 | for (dirpath,dirnames,filenames) in os.walk(base): | |
247 | # we need to strip out the dirpath from the base to map it to the |
|
241 | # we need to strip out the dirpath from the base to map it to the | |
248 | # output (installation) path. This requires possibly stripping the |
|
242 | # output (installation) path. This requires possibly stripping the | |
249 | # path separator, because otherwise pjoin will not work correctly |
|
243 | # path separator, because otherwise pjoin will not work correctly | |
250 | # (pjoin('foo/','/bar') returns '/bar'). |
|
244 | # (pjoin('foo/','/bar') returns '/bar'). | |
251 |
|
245 | |||
252 | dp_eff = dirpath[lbase:] |
|
246 | dp_eff = dirpath[lbase:] | |
253 | if dp_eff.startswith(pathsep): |
|
247 | if dp_eff.startswith(pathsep): | |
254 | dp_eff = dp_eff[lpathsep:] |
|
248 | dp_eff = dp_eff[lpathsep:] | |
255 | # The output path must be anchored at the out_base marker |
|
249 | # The output path must be anchored at the out_base marker | |
256 | out_path = pjoin(out_base,dp_eff) |
|
250 | out_path = pjoin(out_base,dp_eff) | |
257 | # Now we can generate the final filenames. Since os.walk only produces |
|
251 | # Now we can generate the final filenames. Since os.walk only produces | |
258 | # filenames, we must join back with the dirpath to get full valid file |
|
252 | # filenames, we must join back with the dirpath to get full valid file | |
259 | # paths: |
|
253 | # paths: | |
260 | pfiles = [pjoin(dirpath,f) for f in filenames] |
|
254 | pfiles = [pjoin(dirpath,f) for f in filenames] | |
261 | # Finally, generate the entry we need, which is a pari of (output |
|
255 | # Finally, generate the entry we need, which is a pari of (output | |
262 | # path, files) for use as a data_files parameter in install_data. |
|
256 | # path, files) for use as a data_files parameter in install_data. | |
263 | out.append((out_path, pfiles)) |
|
257 | out.append((out_path, pfiles)) | |
264 |
|
258 | |||
265 | return out |
|
259 | return out | |
266 |
|
260 | |||
267 |
|
261 | |||
268 | def find_data_files(): |
|
262 | def find_data_files(): | |
269 | """ |
|
263 | """ | |
270 | Find IPython's data_files. |
|
264 | Find IPython's data_files. | |
271 |
|
265 | |||
272 | Just man pages at this point. |
|
266 | Just man pages at this point. | |
273 | """ |
|
267 | """ | |
274 |
|
268 | |||
275 | manpagebase = pjoin('share', 'man', 'man1') |
|
269 | manpagebase = pjoin('share', 'man', 'man1') | |
276 |
|
270 | |||
277 | # Simple file lists can be made by hand |
|
271 | # Simple file lists can be made by hand | |
278 | manpages = [f for f in glob(pjoin('docs','man','*.1.gz')) if isfile(f)] |
|
272 | manpages = [f for f in glob(pjoin('docs','man','*.1.gz')) if isfile(f)] | |
279 | if not manpages: |
|
273 | if not manpages: | |
280 | # When running from a source tree, the manpages aren't gzipped |
|
274 | # When running from a source tree, the manpages aren't gzipped | |
281 | manpages = [f for f in glob(pjoin('docs','man','*.1')) if isfile(f)] |
|
275 | manpages = [f for f in glob(pjoin('docs','man','*.1')) if isfile(f)] | |
282 |
|
276 | |||
283 | # And assemble the entire output list |
|
277 | # And assemble the entire output list | |
284 | data_files = [ (manpagebase, manpages) ] |
|
278 | data_files = [ (manpagebase, manpages) ] | |
285 |
|
279 | |||
286 | return data_files |
|
280 | return data_files | |
287 |
|
281 | |||
288 |
|
282 | |||
289 | def make_man_update_target(manpage): |
|
283 | def make_man_update_target(manpage): | |
290 | """Return a target_update-compliant tuple for the given manpage. |
|
284 | """Return a target_update-compliant tuple for the given manpage. | |
291 |
|
285 | |||
292 | Parameters |
|
286 | Parameters | |
293 | ---------- |
|
287 | ---------- | |
294 | manpage : string |
|
288 | manpage : string | |
295 | Name of the manpage, must include the section number (trailing number). |
|
289 | Name of the manpage, must include the section number (trailing number). | |
296 |
|
290 | |||
297 | Example |
|
291 | Example | |
298 | ------- |
|
292 | ------- | |
299 |
|
293 | |||
300 | >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE |
|
294 | >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE | |
301 | ('docs/man/ipython.1.gz', |
|
295 | ('docs/man/ipython.1.gz', | |
302 | ['docs/man/ipython.1'], |
|
296 | ['docs/man/ipython.1'], | |
303 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz') |
|
297 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz') | |
304 | """ |
|
298 | """ | |
305 | man_dir = pjoin('docs', 'man') |
|
299 | man_dir = pjoin('docs', 'man') | |
306 | manpage_gz = manpage + '.gz' |
|
300 | manpage_gz = manpage + '.gz' | |
307 | manpath = pjoin(man_dir, manpage) |
|
301 | manpath = pjoin(man_dir, manpage) | |
308 | manpath_gz = pjoin(man_dir, manpage_gz) |
|
302 | manpath_gz = pjoin(man_dir, manpage_gz) | |
309 | gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" % |
|
303 | gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" % | |
310 | locals() ) |
|
304 | locals() ) | |
311 | return (manpath_gz, [manpath], gz_cmd) |
|
305 | return (manpath_gz, [manpath], gz_cmd) | |
312 |
|
306 | |||
313 | # The two functions below are copied from IPython.utils.path, so we don't need |
|
307 | # The two functions below are copied from IPython.utils.path, so we don't need | |
314 | # to import IPython during setup, which fails on Python 3. |
|
308 | # to import IPython during setup, which fails on Python 3. | |
315 |
|
309 | |||
316 | def target_outdated(target,deps): |
|
310 | def target_outdated(target,deps): | |
317 | """Determine whether a target is out of date. |
|
311 | """Determine whether a target is out of date. | |
318 |
|
312 | |||
319 | target_outdated(target,deps) -> 1/0 |
|
313 | target_outdated(target,deps) -> 1/0 | |
320 |
|
314 | |||
321 | deps: list of filenames which MUST exist. |
|
315 | deps: list of filenames which MUST exist. | |
322 | target: single filename which may or may not exist. |
|
316 | target: single filename which may or may not exist. | |
323 |
|
317 | |||
324 | If target doesn't exist or is older than any file listed in deps, return |
|
318 | If target doesn't exist or is older than any file listed in deps, return | |
325 | true, otherwise return false. |
|
319 | true, otherwise return false. | |
326 | """ |
|
320 | """ | |
327 | try: |
|
321 | try: | |
328 | target_time = os.path.getmtime(target) |
|
322 | target_time = os.path.getmtime(target) | |
329 | except os.error: |
|
323 | except os.error: | |
330 | return 1 |
|
324 | return 1 | |
331 | for dep in deps: |
|
325 | for dep in deps: | |
332 | dep_time = os.path.getmtime(dep) |
|
326 | dep_time = os.path.getmtime(dep) | |
333 | if dep_time > target_time: |
|
327 | if dep_time > target_time: | |
334 | #print "For target",target,"Dep failed:",dep # dbg |
|
328 | #print "For target",target,"Dep failed:",dep # dbg | |
335 | #print "times (dep,tar):",dep_time,target_time # dbg |
|
329 | #print "times (dep,tar):",dep_time,target_time # dbg | |
336 | return 1 |
|
330 | return 1 | |
337 | return 0 |
|
331 | return 0 | |
338 |
|
332 | |||
339 |
|
333 | |||
340 | def target_update(target,deps,cmd): |
|
334 | def target_update(target,deps,cmd): | |
341 | """Update a target with a given command given a list of dependencies. |
|
335 | """Update a target with a given command given a list of dependencies. | |
342 |
|
336 | |||
343 | target_update(target,deps,cmd) -> runs cmd if target is outdated. |
|
337 | target_update(target,deps,cmd) -> runs cmd if target is outdated. | |
344 |
|
338 | |||
345 | This is just a wrapper around target_outdated() which calls the given |
|
339 | This is just a wrapper around target_outdated() which calls the given | |
346 | command if target is outdated.""" |
|
340 | command if target is outdated.""" | |
347 |
|
341 | |||
348 | if target_outdated(target,deps): |
|
342 | if target_outdated(target,deps): | |
349 | os.system(cmd) |
|
343 | os.system(cmd) | |
350 |
|
344 | |||
351 | #--------------------------------------------------------------------------- |
|
345 | #--------------------------------------------------------------------------- | |
352 | # Find scripts |
|
346 | # Find scripts | |
353 | #--------------------------------------------------------------------------- |
|
347 | #--------------------------------------------------------------------------- | |
354 |
|
348 | |||
355 | def find_entry_points(): |
|
349 | def find_entry_points(): | |
356 | """Find IPython's scripts. |
|
350 | """Find IPython's scripts. | |
357 |
|
351 | |||
358 | if entry_points is True: |
|
352 | if entry_points is True: | |
359 | return setuptools entry_point-style definitions |
|
353 | return setuptools entry_point-style definitions | |
360 | else: |
|
354 | else: | |
361 | return file paths of plain scripts [default] |
|
355 | return file paths of plain scripts [default] | |
362 |
|
356 | |||
363 | suffix is appended to script names if entry_points is True, so that the |
|
357 | suffix is appended to script names if entry_points is True, so that the | |
364 | Python 3 scripts get named "ipython3" etc. |
|
358 | Python 3 scripts get named "ipython3" etc. | |
365 | """ |
|
359 | """ | |
366 | ep = [ |
|
360 | ep = [ | |
367 | 'ipython%s = IPython:start_ipython', |
|
361 | 'ipython%s = IPython:start_ipython', | |
368 | 'ipcontroller%s = IPython.parallel.apps.ipcontrollerapp:launch_new_instance', |
|
362 | 'ipcontroller%s = IPython.parallel.apps.ipcontrollerapp:launch_new_instance', | |
369 | 'ipengine%s = IPython.parallel.apps.ipengineapp:launch_new_instance', |
|
363 | 'ipengine%s = IPython.parallel.apps.ipengineapp:launch_new_instance', | |
370 | 'ipcluster%s = IPython.parallel.apps.ipclusterapp:launch_new_instance', |
|
364 | 'ipcluster%s = IPython.parallel.apps.ipclusterapp:launch_new_instance', | |
371 | 'iptest%s = IPython.testing.iptestcontroller:main', |
|
365 | 'iptest%s = IPython.testing.iptestcontroller:main', | |
372 | ] |
|
366 | ] | |
373 | suffix = str(sys.version_info[0]) |
|
367 | suffix = str(sys.version_info[0]) | |
374 | return [e % '' for e in ep] + [e % suffix for e in ep] |
|
368 | return [e % '' for e in ep] + [e % suffix for e in ep] | |
375 |
|
369 | |||
376 | script_src = """#!{executable} |
|
370 | script_src = """#!{executable} | |
377 | # This script was automatically generated by setup.py |
|
371 | # This script was automatically generated by setup.py | |
378 | if __name__ == '__main__': |
|
372 | if __name__ == '__main__': | |
379 | from {mod} import {func} |
|
373 | from {mod} import {func} | |
380 | {func}() |
|
374 | {func}() | |
381 | """ |
|
375 | """ | |
382 |
|
376 | |||
383 | class build_scripts_entrypt(build_scripts): |
|
377 | class build_scripts_entrypt(build_scripts): | |
384 | def run(self): |
|
378 | def run(self): | |
385 | self.mkpath(self.build_dir) |
|
379 | self.mkpath(self.build_dir) | |
386 | outfiles = [] |
|
380 | outfiles = [] | |
387 | for script in find_entry_points(): |
|
381 | for script in find_entry_points(): | |
388 | name, entrypt = script.split('=') |
|
382 | name, entrypt = script.split('=') | |
389 | name = name.strip() |
|
383 | name = name.strip() | |
390 | entrypt = entrypt.strip() |
|
384 | entrypt = entrypt.strip() | |
391 | outfile = os.path.join(self.build_dir, name) |
|
385 | outfile = os.path.join(self.build_dir, name) | |
392 | outfiles.append(outfile) |
|
386 | outfiles.append(outfile) | |
393 | print('Writing script to', outfile) |
|
387 | print('Writing script to', outfile) | |
394 |
|
388 | |||
395 | mod, func = entrypt.split(':') |
|
389 | mod, func = entrypt.split(':') | |
396 | with open(outfile, 'w') as f: |
|
390 | with open(outfile, 'w') as f: | |
397 | f.write(script_src.format(executable=sys.executable, |
|
391 | f.write(script_src.format(executable=sys.executable, | |
398 | mod=mod, func=func)) |
|
392 | mod=mod, func=func)) | |
399 |
|
393 | |||
400 | return outfiles, outfiles |
|
394 | return outfiles, outfiles | |
401 |
|
395 | |||
402 | class install_lib_symlink(Command): |
|
396 | class install_lib_symlink(Command): | |
403 | user_options = [ |
|
397 | user_options = [ | |
404 | ('install-dir=', 'd', "directory to install to"), |
|
398 | ('install-dir=', 'd', "directory to install to"), | |
405 | ] |
|
399 | ] | |
406 |
|
400 | |||
407 | def initialize_options(self): |
|
401 | def initialize_options(self): | |
408 | self.install_dir = None |
|
402 | self.install_dir = None | |
409 |
|
403 | |||
410 | def finalize_options(self): |
|
404 | def finalize_options(self): | |
411 | self.set_undefined_options('symlink', |
|
405 | self.set_undefined_options('symlink', | |
412 | ('install_lib', 'install_dir'), |
|
406 | ('install_lib', 'install_dir'), | |
413 | ) |
|
407 | ) | |
414 |
|
408 | |||
415 | def run(self): |
|
409 | def run(self): | |
416 | if sys.platform == 'win32': |
|
410 | if sys.platform == 'win32': | |
417 | raise Exception("This doesn't work on Windows.") |
|
411 | raise Exception("This doesn't work on Windows.") | |
418 | pkg = os.path.join(os.getcwd(), 'IPython') |
|
412 | pkg = os.path.join(os.getcwd(), 'IPython') | |
419 | dest = os.path.join(self.install_dir, 'IPython') |
|
413 | dest = os.path.join(self.install_dir, 'IPython') | |
420 | if os.path.islink(dest): |
|
414 | if os.path.islink(dest): | |
421 | print('removing existing symlink at %s' % dest) |
|
415 | print('removing existing symlink at %s' % dest) | |
422 | os.unlink(dest) |
|
416 | os.unlink(dest) | |
423 | print('symlinking %s -> %s' % (pkg, dest)) |
|
417 | print('symlinking %s -> %s' % (pkg, dest)) | |
424 | os.symlink(pkg, dest) |
|
418 | os.symlink(pkg, dest) | |
425 |
|
419 | |||
426 | class unsymlink(install): |
|
420 | class unsymlink(install): | |
427 | def run(self): |
|
421 | def run(self): | |
428 | dest = os.path.join(self.install_lib, 'IPython') |
|
422 | dest = os.path.join(self.install_lib, 'IPython') | |
429 | if os.path.islink(dest): |
|
423 | if os.path.islink(dest): | |
430 | print('removing symlink at %s' % dest) |
|
424 | print('removing symlink at %s' % dest) | |
431 | os.unlink(dest) |
|
425 | os.unlink(dest) | |
432 | else: |
|
426 | else: | |
433 | print('No symlink exists at %s' % dest) |
|
427 | print('No symlink exists at %s' % dest) | |
434 |
|
428 | |||
435 | class install_symlinked(install): |
|
429 | class install_symlinked(install): | |
436 | def run(self): |
|
430 | def run(self): | |
437 | if sys.platform == 'win32': |
|
431 | if sys.platform == 'win32': | |
438 | raise Exception("This doesn't work on Windows.") |
|
432 | raise Exception("This doesn't work on Windows.") | |
439 |
|
433 | |||
440 | # Run all sub-commands (at least those that need to be run) |
|
434 | # Run all sub-commands (at least those that need to be run) | |
441 | for cmd_name in self.get_sub_commands(): |
|
435 | for cmd_name in self.get_sub_commands(): | |
442 | self.run_command(cmd_name) |
|
436 | self.run_command(cmd_name) | |
443 |
|
437 | |||
444 | # 'sub_commands': a list of commands this command might have to run to |
|
438 | # 'sub_commands': a list of commands this command might have to run to | |
445 | # get its work done. See cmd.py for more info. |
|
439 | # get its work done. See cmd.py for more info. | |
446 | sub_commands = [('install_lib_symlink', lambda self:True), |
|
440 | sub_commands = [('install_lib_symlink', lambda self:True), | |
447 | ('install_scripts_sym', lambda self:True), |
|
441 | ('install_scripts_sym', lambda self:True), | |
448 | ] |
|
442 | ] | |
449 |
|
443 | |||
450 | class install_scripts_for_symlink(install_scripts): |
|
444 | class install_scripts_for_symlink(install_scripts): | |
451 | """Redefined to get options from 'symlink' instead of 'install'. |
|
445 | """Redefined to get options from 'symlink' instead of 'install'. | |
452 |
|
446 | |||
453 | I love distutils almost as much as I love setuptools. |
|
447 | I love distutils almost as much as I love setuptools. | |
454 | """ |
|
448 | """ | |
455 | def finalize_options(self): |
|
449 | def finalize_options(self): | |
456 | self.set_undefined_options('build', ('build_scripts', 'build_dir')) |
|
450 | self.set_undefined_options('build', ('build_scripts', 'build_dir')) | |
457 | self.set_undefined_options('symlink', |
|
451 | self.set_undefined_options('symlink', | |
458 | ('install_scripts', 'install_dir'), |
|
452 | ('install_scripts', 'install_dir'), | |
459 | ('force', 'force'), |
|
453 | ('force', 'force'), | |
460 | ('skip_build', 'skip_build'), |
|
454 | ('skip_build', 'skip_build'), | |
461 | ) |
|
455 | ) | |
462 |
|
456 | |||
463 | #--------------------------------------------------------------------------- |
|
457 | #--------------------------------------------------------------------------- | |
464 | # Verify all dependencies |
|
458 | # Verify all dependencies | |
465 | #--------------------------------------------------------------------------- |
|
459 | #--------------------------------------------------------------------------- | |
466 |
|
460 | |||
467 | def check_for_dependencies(): |
|
461 | def check_for_dependencies(): | |
468 | """Check for IPython's dependencies. |
|
462 | """Check for IPython's dependencies. | |
469 |
|
463 | |||
470 | This function should NOT be called if running under setuptools! |
|
464 | This function should NOT be called if running under setuptools! | |
471 | """ |
|
465 | """ | |
472 | from setupext.setupext import ( |
|
466 | from setupext.setupext import ( | |
473 | print_line, print_raw, print_status, |
|
467 | print_line, print_raw, print_status, | |
474 | check_for_sphinx, check_for_pygments, |
|
468 | check_for_sphinx, check_for_pygments, | |
475 | check_for_nose, check_for_pexpect, |
|
469 | check_for_nose, check_for_pexpect, | |
476 | check_for_pyzmq, check_for_readline, |
|
470 | check_for_pyzmq, check_for_readline, | |
477 | check_for_jinja2, check_for_tornado |
|
471 | check_for_jinja2, check_for_tornado | |
478 | ) |
|
472 | ) | |
479 | print_line() |
|
473 | print_line() | |
480 | print_raw("BUILDING IPYTHON") |
|
474 | print_raw("BUILDING IPYTHON") | |
481 | print_status('python', sys.version) |
|
475 | print_status('python', sys.version) | |
482 | print_status('platform', sys.platform) |
|
476 | print_status('platform', sys.platform) | |
483 | if sys.platform == 'win32': |
|
477 | if sys.platform == 'win32': | |
484 | print_status('Windows version', sys.getwindowsversion()) |
|
478 | print_status('Windows version', sys.getwindowsversion()) | |
485 |
|
479 | |||
486 | print_raw("") |
|
480 | print_raw("") | |
487 | print_raw("OPTIONAL DEPENDENCIES") |
|
481 | print_raw("OPTIONAL DEPENDENCIES") | |
488 |
|
482 | |||
489 | check_for_sphinx() |
|
483 | check_for_sphinx() | |
490 | check_for_pygments() |
|
484 | check_for_pygments() | |
491 | check_for_nose() |
|
485 | check_for_nose() | |
492 | if os.name == 'posix': |
|
486 | if os.name == 'posix': | |
493 | check_for_pexpect() |
|
487 | check_for_pexpect() | |
494 | check_for_pyzmq() |
|
488 | check_for_pyzmq() | |
495 | check_for_tornado() |
|
489 | check_for_tornado() | |
496 | check_for_readline() |
|
490 | check_for_readline() | |
497 | check_for_jinja2() |
|
491 | check_for_jinja2() | |
498 |
|
492 | |||
499 | #--------------------------------------------------------------------------- |
|
493 | #--------------------------------------------------------------------------- | |
500 | # VCS related |
|
494 | # VCS related | |
501 | #--------------------------------------------------------------------------- |
|
495 | #--------------------------------------------------------------------------- | |
502 |
|
496 | |||
503 | # utils.submodule has checks for submodule status |
|
497 | # utils.submodule has checks for submodule status | |
504 | execfile(pjoin('IPython','utils','submodule.py'), globals()) |
|
498 | execfile(pjoin('IPython','utils','submodule.py'), globals()) | |
505 |
|
499 | |||
506 | class UpdateSubmodules(Command): |
|
500 | class UpdateSubmodules(Command): | |
507 | """Update git submodules |
|
501 | """Update git submodules | |
508 |
|
502 | |||
509 | IPython's external javascript dependencies live in a separate repo. |
|
503 | IPython's external javascript dependencies live in a separate repo. | |
510 | """ |
|
504 | """ | |
511 | description = "Update git submodules" |
|
505 | description = "Update git submodules" | |
512 | user_options = [] |
|
506 | user_options = [] | |
513 |
|
507 | |||
514 | def initialize_options(self): |
|
508 | def initialize_options(self): | |
515 | pass |
|
509 | pass | |
516 |
|
510 | |||
517 | def finalize_options(self): |
|
511 | def finalize_options(self): | |
518 | pass |
|
512 | pass | |
519 |
|
513 | |||
520 | def run(self): |
|
514 | def run(self): | |
521 | failure = False |
|
515 | failure = False | |
522 | try: |
|
516 | try: | |
523 | self.spawn('git submodule init'.split()) |
|
517 | self.spawn('git submodule init'.split()) | |
524 | self.spawn('git submodule update --recursive'.split()) |
|
518 | self.spawn('git submodule update --recursive'.split()) | |
525 | except Exception as e: |
|
519 | except Exception as e: | |
526 | failure = e |
|
520 | failure = e | |
527 | print(e) |
|
521 | print(e) | |
528 |
|
522 | |||
529 | if not check_submodule_status(repo_root) == 'clean': |
|
523 | if not check_submodule_status(repo_root) == 'clean': | |
530 | print("submodules could not be checked out") |
|
524 | print("submodules could not be checked out") | |
531 | sys.exit(1) |
|
525 | sys.exit(1) | |
532 |
|
526 | |||
533 |
|
527 | |||
534 | def git_prebuild(pkg_dir, build_cmd=build_py): |
|
528 | def git_prebuild(pkg_dir, build_cmd=build_py): | |
535 | """Return extended build or sdist command class for recording commit |
|
529 | """Return extended build or sdist command class for recording commit | |
536 |
|
530 | |||
537 | records git commit in IPython.utils._sysinfo.commit |
|
531 | records git commit in IPython.utils._sysinfo.commit | |
538 |
|
532 | |||
539 | for use in IPython.utils.sysinfo.sys_info() calls after installation. |
|
533 | for use in IPython.utils.sysinfo.sys_info() calls after installation. | |
540 |
|
534 | |||
541 | Also ensures that submodules exist prior to running |
|
535 | Also ensures that submodules exist prior to running | |
542 | """ |
|
536 | """ | |
543 |
|
537 | |||
544 | class MyBuildPy(build_cmd): |
|
538 | class MyBuildPy(build_cmd): | |
545 | ''' Subclass to write commit data into installation tree ''' |
|
539 | ''' Subclass to write commit data into installation tree ''' | |
546 | def run(self): |
|
540 | def run(self): | |
547 | build_cmd.run(self) |
|
541 | build_cmd.run(self) | |
548 | # this one will only fire for build commands |
|
542 | # this one will only fire for build commands | |
549 | if hasattr(self, 'build_lib'): |
|
543 | if hasattr(self, 'build_lib'): | |
550 | self._record_commit(self.build_lib) |
|
544 | self._record_commit(self.build_lib) | |
551 |
|
545 | |||
552 | def make_release_tree(self, base_dir, files): |
|
546 | def make_release_tree(self, base_dir, files): | |
553 | # this one will fire for sdist |
|
547 | # this one will fire for sdist | |
554 | build_cmd.make_release_tree(self, base_dir, files) |
|
548 | build_cmd.make_release_tree(self, base_dir, files) | |
555 | self._record_commit(base_dir) |
|
549 | self._record_commit(base_dir) | |
556 |
|
550 | |||
557 | def _record_commit(self, base_dir): |
|
551 | def _record_commit(self, base_dir): | |
558 | import subprocess |
|
552 | import subprocess | |
559 | proc = subprocess.Popen('git rev-parse --short HEAD', |
|
553 | proc = subprocess.Popen('git rev-parse --short HEAD', | |
560 | stdout=subprocess.PIPE, |
|
554 | stdout=subprocess.PIPE, | |
561 | stderr=subprocess.PIPE, |
|
555 | stderr=subprocess.PIPE, | |
562 | shell=True) |
|
556 | shell=True) | |
563 | repo_commit, _ = proc.communicate() |
|
557 | repo_commit, _ = proc.communicate() | |
564 | repo_commit = repo_commit.strip().decode("ascii") |
|
558 | repo_commit = repo_commit.strip().decode("ascii") | |
565 |
|
559 | |||
566 | out_pth = pjoin(base_dir, pkg_dir, 'utils', '_sysinfo.py') |
|
560 | out_pth = pjoin(base_dir, pkg_dir, 'utils', '_sysinfo.py') | |
567 | if os.path.isfile(out_pth) and not repo_commit: |
|
561 | if os.path.isfile(out_pth) and not repo_commit: | |
568 | # nothing to write, don't clobber |
|
562 | # nothing to write, don't clobber | |
569 | return |
|
563 | return | |
570 |
|
564 | |||
571 | print("writing git commit '%s' to %s" % (repo_commit, out_pth)) |
|
565 | print("writing git commit '%s' to %s" % (repo_commit, out_pth)) | |
572 |
|
566 | |||
573 | # remove to avoid overwriting original via hard link |
|
567 | # remove to avoid overwriting original via hard link | |
574 | try: |
|
568 | try: | |
575 | os.remove(out_pth) |
|
569 | os.remove(out_pth) | |
576 | except (IOError, OSError): |
|
570 | except (IOError, OSError): | |
577 | pass |
|
571 | pass | |
578 | with open(out_pth, 'w') as out_file: |
|
572 | with open(out_pth, 'w') as out_file: | |
579 | out_file.writelines([ |
|
573 | out_file.writelines([ | |
580 | '# GENERATED BY setup.py\n', |
|
574 | '# GENERATED BY setup.py\n', | |
581 | 'commit = "%s"\n' % repo_commit, |
|
575 | 'commit = "%s"\n' % repo_commit, | |
582 | ]) |
|
576 | ]) | |
583 | return require_submodules(MyBuildPy) |
|
577 | return require_submodules(MyBuildPy) | |
584 |
|
578 | |||
585 |
|
579 | |||
586 | def require_submodules(command): |
|
580 | def require_submodules(command): | |
587 | """decorator for instructing a command to check for submodules before running""" |
|
581 | """decorator for instructing a command to check for submodules before running""" | |
588 | class DecoratedCommand(command): |
|
582 | class DecoratedCommand(command): | |
589 | def run(self): |
|
583 | def run(self): | |
590 | if not check_submodule_status(repo_root) == 'clean': |
|
584 | if not check_submodule_status(repo_root) == 'clean': | |
591 | print("submodules missing! Run `setup.py submodule` and try again") |
|
585 | print("submodules missing! Run `setup.py submodule` and try again") | |
592 | sys.exit(1) |
|
586 | sys.exit(1) | |
593 | command.run(self) |
|
587 | command.run(self) | |
594 | return DecoratedCommand |
|
588 | return DecoratedCommand | |
595 |
|
589 | |||
596 | #--------------------------------------------------------------------------- |
|
590 | #--------------------------------------------------------------------------- | |
597 | # bdist related |
|
591 | # bdist related | |
598 | #--------------------------------------------------------------------------- |
|
592 | #--------------------------------------------------------------------------- | |
599 |
|
593 | |||
600 | def get_bdist_wheel(): |
|
594 | def get_bdist_wheel(): | |
601 | """Construct bdist_wheel command for building wheels |
|
595 | """Construct bdist_wheel command for building wheels | |
602 |
|
596 | |||
603 | Constructs py2-none-any tag, instead of py2.7-none-any |
|
597 | Constructs py2-none-any tag, instead of py2.7-none-any | |
604 | """ |
|
598 | """ | |
605 | class RequiresWheel(Command): |
|
599 | class RequiresWheel(Command): | |
606 | description = "Dummy command for missing bdist_wheel" |
|
600 | description = "Dummy command for missing bdist_wheel" | |
607 | user_options = [] |
|
601 | user_options = [] | |
608 |
|
602 | |||
609 | def initialize_options(self): |
|
603 | def initialize_options(self): | |
610 | pass |
|
604 | pass | |
611 |
|
605 | |||
612 | def finalize_options(self): |
|
606 | def finalize_options(self): | |
613 | pass |
|
607 | pass | |
614 |
|
608 | |||
615 | def run(self): |
|
609 | def run(self): | |
616 | print("bdist_wheel requires the wheel package") |
|
610 | print("bdist_wheel requires the wheel package") | |
617 | sys.exit(1) |
|
611 | sys.exit(1) | |
618 |
|
612 | |||
619 | if 'setuptools' not in sys.modules: |
|
613 | if 'setuptools' not in sys.modules: | |
620 | return RequiresWheel |
|
614 | return RequiresWheel | |
621 | else: |
|
615 | else: | |
622 | try: |
|
616 | try: | |
623 | from wheel.bdist_wheel import bdist_wheel, read_pkg_info, write_pkg_info |
|
617 | from wheel.bdist_wheel import bdist_wheel, read_pkg_info, write_pkg_info | |
624 | except ImportError: |
|
618 | except ImportError: | |
625 | return RequiresWheel |
|
619 | return RequiresWheel | |
626 |
|
620 | |||
627 | class bdist_wheel_tag(bdist_wheel): |
|
621 | class bdist_wheel_tag(bdist_wheel): | |
628 |
|
622 | |||
629 | def add_requirements(self, metadata_path): |
|
623 | def add_requirements(self, metadata_path): | |
630 | """transform platform-dependent requirements""" |
|
624 | """transform platform-dependent requirements""" | |
631 | pkg_info = read_pkg_info(metadata_path) |
|
625 | pkg_info = read_pkg_info(metadata_path) | |
632 | # pkg_info is an email.Message object (?!) |
|
626 | # pkg_info is an email.Message object (?!) | |
633 | # we have to remove the unconditional 'readline' and/or 'pyreadline' entries |
|
627 | # we have to remove the unconditional 'readline' and/or 'pyreadline' entries | |
634 | # and transform them to conditionals |
|
628 | # and transform them to conditionals | |
635 | requires = pkg_info.get_all('Requires-Dist') |
|
629 | requires = pkg_info.get_all('Requires-Dist') | |
636 | del pkg_info['Requires-Dist'] |
|
630 | del pkg_info['Requires-Dist'] | |
637 | def _remove_startswith(lis, prefix): |
|
631 | def _remove_startswith(lis, prefix): | |
638 | """like list.remove, but with startswith instead of ==""" |
|
632 | """like list.remove, but with startswith instead of ==""" | |
639 | found = False |
|
633 | found = False | |
640 | for idx, item in enumerate(lis): |
|
634 | for idx, item in enumerate(lis): | |
641 | if item.startswith(prefix): |
|
635 | if item.startswith(prefix): | |
642 | found = True |
|
636 | found = True | |
643 | break |
|
637 | break | |
644 | if found: |
|
638 | if found: | |
645 | lis.pop(idx) |
|
639 | lis.pop(idx) | |
646 |
|
640 | |||
647 | for pkg in ("gnureadline", "pyreadline", "mock"): |
|
641 | for pkg in ("gnureadline", "pyreadline", "mock"): | |
648 | _remove_startswith(requires, pkg) |
|
642 | _remove_startswith(requires, pkg) | |
649 | requires.append("gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'") |
|
643 | requires.append("gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'") | |
650 | requires.append("pyreadline (>=2.0); sys.platform == 'win32' and platform.python_implementation == 'CPython'") |
|
644 | requires.append("pyreadline (>=2.0); extra == 'terminal' and sys.platform == 'win32' and platform.python_implementation == 'CPython'") | |
|
645 | requires.append("pyreadline (>=2.0); extra == 'all' and sys.platform == 'win32' and platform.python_implementation == 'CPython'") | |||
651 | requires.append("mock; extra == 'test' and python_version < '3.3'") |
|
646 | requires.append("mock; extra == 'test' and python_version < '3.3'") | |
652 | for r in requires: |
|
647 | for r in requires: | |
653 | pkg_info['Requires-Dist'] = r |
|
648 | pkg_info['Requires-Dist'] = r | |
654 | write_pkg_info(metadata_path, pkg_info) |
|
649 | write_pkg_info(metadata_path, pkg_info) | |
655 |
|
650 | |||
656 | return bdist_wheel_tag |
|
651 | return bdist_wheel_tag | |
657 |
|
652 | |||
658 | #--------------------------------------------------------------------------- |
|
653 | #--------------------------------------------------------------------------- | |
659 | # Notebook related |
|
654 | # Notebook related | |
660 | #--------------------------------------------------------------------------- |
|
655 | #--------------------------------------------------------------------------- | |
661 |
|
656 | |||
662 | class CompileCSS(Command): |
|
657 | class CompileCSS(Command): | |
663 | """Recompile Notebook CSS |
|
658 | """Recompile Notebook CSS | |
664 |
|
659 | |||
665 | Regenerate the compiled CSS from LESS sources. |
|
660 | Regenerate the compiled CSS from LESS sources. | |
666 |
|
661 | |||
667 | Requires various dev dependencies, such as fabric and lessc. |
|
662 | Requires various dev dependencies, such as fabric and lessc. | |
668 | """ |
|
663 | """ | |
669 | description = "Recompile Notebook CSS" |
|
664 | description = "Recompile Notebook CSS" | |
670 | user_options = [] |
|
665 | user_options = [] | |
671 |
|
666 | |||
672 | def initialize_options(self): |
|
667 | def initialize_options(self): | |
673 | pass |
|
668 | pass | |
674 |
|
669 | |||
675 | def finalize_options(self): |
|
670 | def finalize_options(self): | |
676 | pass |
|
671 | pass | |
677 |
|
672 | |||
678 | def run(self): |
|
673 | def run(self): | |
679 | call("fab css", shell=True, cwd=pjoin(repo_root, "IPython", "html")) |
|
674 | call("fab css", shell=True, cwd=pjoin(repo_root, "IPython", "html")) | |
680 |
|
675 | |||
681 | class JavascriptVersion(Command): |
|
676 | class JavascriptVersion(Command): | |
682 | """write the javascript version to notebook javascript""" |
|
677 | """write the javascript version to notebook javascript""" | |
683 | description = "Write IPython version to javascript" |
|
678 | description = "Write IPython version to javascript" | |
684 | user_options = [] |
|
679 | user_options = [] | |
685 |
|
680 | |||
686 | def initialize_options(self): |
|
681 | def initialize_options(self): | |
687 | pass |
|
682 | pass | |
688 |
|
683 | |||
689 | def finalize_options(self): |
|
684 | def finalize_options(self): | |
690 | pass |
|
685 | pass | |
691 |
|
686 | |||
692 | def run(self): |
|
687 | def run(self): | |
693 | nsfile = pjoin(repo_root, "IPython", "html", "static", "base", "js", "namespace.js") |
|
688 | nsfile = pjoin(repo_root, "IPython", "html", "static", "base", "js", "namespace.js") | |
694 | with open(nsfile) as f: |
|
689 | with open(nsfile) as f: | |
695 | lines = f.readlines() |
|
690 | lines = f.readlines() | |
696 | with open(nsfile, 'w') as f: |
|
691 | with open(nsfile, 'w') as f: | |
697 | for line in lines: |
|
692 | for line in lines: | |
698 | if line.startswith("IPython.version"): |
|
693 | if line.startswith("IPython.version"): | |
699 | line = 'IPython.version = "{0}";\n'.format(version) |
|
694 | line = 'IPython.version = "{0}";\n'.format(version) | |
700 | f.write(line) |
|
695 | f.write(line) | |
701 |
|
696 |
General Comments 0
You need to be logged in to leave comments.
Login now