Show More
@@ -18,6 +18,12 b' import os, sys' | |||||
18 | this_dir = os.path.dirname(sys.argv[0]) |
|
18 | this_dir = os.path.dirname(sys.argv[0]) | |
19 | sys.path.insert(0, this_dir) |
|
19 | sys.path.insert(0, this_dir) | |
20 |
|
20 | |||
|
21 | from setupbase import check_for_submodules, update_submodules | |||
|
22 | ||||
|
23 | if not check_for_submodules(): | |||
|
24 | update_submodules() | |||
|
25 | ||||
|
26 | ||||
21 | # Now proceed with execution |
|
27 | # Now proceed with execution | |
22 | execfile(os.path.join( |
|
28 | execfile(os.path.join( | |
23 | this_dir, 'IPython', 'scripts', 'ipython' |
|
29 | this_dir, 'IPython', 'scripts', 'ipython' |
@@ -67,7 +67,11 b' from setupbase import (' | |||||
67 | find_scripts, |
|
67 | find_scripts, | |
68 | find_data_files, |
|
68 | find_data_files, | |
69 | check_for_dependencies, |
|
69 | check_for_dependencies, | |
70 | record_commit_info, |
|
70 | git_prebuild, | |
|
71 | check_for_submodules, | |||
|
72 | update_submodules, | |||
|
73 | require_submodules, | |||
|
74 | UpdateSubmodules, | |||
71 | ) |
|
75 | ) | |
72 | from setupext import setupext |
|
76 | from setupext import setupext | |
73 |
|
77 | |||
@@ -106,6 +110,25 b" if os_name == 'windows' and 'sdist' in sys.argv:" | |||||
106 | sys.exit(1) |
|
110 | sys.exit(1) | |
107 |
|
111 | |||
108 | #------------------------------------------------------------------------------- |
|
112 | #------------------------------------------------------------------------------- | |
|
113 | # Make sure we aren't trying to run without submodules | |||
|
114 | #------------------------------------------------------------------------------- | |||
|
115 | ||||
|
116 | def ensure_submodules_exist(): | |||
|
117 | """Check out git submodules before distutils can do anything | |||
|
118 | ||||
|
119 | Because distutils cannot be trusted to update the tree | |||
|
120 | after everything has been set in motion. | |||
|
121 | """ | |||
|
122 | # don't do anything if nothing is actually supposed to happen | |||
|
123 | for do_nothing in ('-h', '--help', '--help-commands', 'clean'): | |||
|
124 | if do_nothing in sys.argv: | |||
|
125 | return | |||
|
126 | if not check_for_submodules(): | |||
|
127 | update_submodules() | |||
|
128 | ||||
|
129 | ensure_submodules_exist() | |||
|
130 | ||||
|
131 | #------------------------------------------------------------------------------- | |||
109 | # Things related to the IPython documentation |
|
132 | # Things related to the IPython documentation | |
110 | #------------------------------------------------------------------------------- |
|
133 | #------------------------------------------------------------------------------- | |
111 |
|
134 | |||
@@ -193,9 +216,10 b' class UploadWindowsInstallers(upload):' | |||||
193 | self.upload_file('bdist_wininst', 'any', dist_file) |
|
216 | self.upload_file('bdist_wininst', 'any', dist_file) | |
194 |
|
217 | |||
195 | setup_args['cmdclass'] = { |
|
218 | setup_args['cmdclass'] = { | |
196 |
'build_py': |
|
219 | 'build_py': git_prebuild('IPython'), | |
197 |
'sdist' : |
|
220 | 'sdist' : git_prebuild('IPython', sdist), | |
198 | 'upload_wininst' : UploadWindowsInstallers, |
|
221 | 'upload_wininst' : UploadWindowsInstallers, | |
|
222 | 'submodule' : UpdateSubmodules, | |||
199 | } |
|
223 | } | |
200 |
|
224 | |||
201 | #--------------------------------------------------------------------------- |
|
225 | #--------------------------------------------------------------------------- | |
@@ -223,6 +247,10 b' if len(needs_setuptools.intersection(sys.argv)) > 0:' | |||||
223 | setuptools_extra_args = {} |
|
247 | setuptools_extra_args = {} | |
224 |
|
248 | |||
225 | if 'setuptools' in sys.modules: |
|
249 | if 'setuptools' in sys.modules: | |
|
250 | # setup.py develop should check for submodules | |||
|
251 | from setuptools.command.develop import develop | |||
|
252 | setup_args['cmdclass']['develop'] = require_submodules(develop) | |||
|
253 | ||||
226 | setuptools_extra_args['zip_safe'] = False |
|
254 | setuptools_extra_args['zip_safe'] = False | |
227 | setuptools_extra_args['entry_points'] = find_scripts(True) |
|
255 | setuptools_extra_args['entry_points'] = find_scripts(True) | |
228 | setup_args['extras_require'] = dict( |
|
256 | setup_args['extras_require'] = dict( | |
@@ -277,7 +305,7 b" if 'setuptools' in sys.modules:" | |||||
277 | 'lib2to3.fixes.fix_tuple_params', |
|
305 | 'lib2to3.fixes.fix_tuple_params', | |
278 | ] |
|
306 | ] | |
279 | from setuptools.command.build_py import build_py |
|
307 | from setuptools.command.build_py import build_py | |
280 |
setup_args['cmdclass'] = {'build_py': |
|
308 | setup_args['cmdclass'] = {'build_py': git_prebuild('IPython', build_cmd=build_py)} | |
281 | setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3') |
|
309 | setuptools_extra_args['entry_points'] = find_scripts(True, suffix='3') | |
282 | setuptools._dont_write_bytecode = True |
|
310 | setuptools._dont_write_bytecode = True | |
283 | else: |
|
311 | else: |
@@ -28,6 +28,7 b' try:' | |||||
28 | except: |
|
28 | except: | |
29 | from ConfigParser import ConfigParser |
|
29 | from ConfigParser import ConfigParser | |
30 | from distutils.command.build_py import build_py |
|
30 | from distutils.command.build_py import build_py | |
|
31 | from distutils.cmd import Command | |||
31 | from glob import glob |
|
32 | from glob import glob | |
32 |
|
33 | |||
33 | from setupext import install_data_ext |
|
34 | from setupext import install_data_ext | |
@@ -368,17 +369,79 b' def check_for_dependencies():' | |||||
368 | check_for_pyzmq() |
|
369 | check_for_pyzmq() | |
369 | check_for_readline() |
|
370 | check_for_readline() | |
370 |
|
371 | |||
371 | def record_commit_info(pkg_dir, build_cmd=build_py): |
|
372 | #--------------------------------------------------------------------------- | |
372 | """ Return extended build or sdist command class for recording commit |
|
373 | # VCS related | |
|
374 | #--------------------------------------------------------------------------- | |||
|
375 | ||||
|
376 | def check_for_submodules(): | |||
|
377 | """return False if there are any submodules that need to be checked out, | |||
|
378 | True otherwise. | |||
|
379 | ||||
|
380 | This doesn't check if they are up to date, only existence. | |||
|
381 | """ | |||
|
382 | here = os.path.dirname(__file__) | |||
|
383 | submodules = [ | |||
|
384 | os.path.join(here, 'IPython', 'frontend', 'html', 'notebook', 'static', 'external') | |||
|
385 | ] | |||
|
386 | for submodule in submodules: | |||
|
387 | if not os.path.exists(submodule): | |||
|
388 | return False | |||
|
389 | return True | |||
|
390 | ||||
|
391 | def update_submodules(): | |||
|
392 | """update git submodules""" | |||
|
393 | import subprocess | |||
|
394 | print("updating git submodules") | |||
|
395 | subprocess.check_call('git submodule init'.split()) | |||
|
396 | subprocess.check_call('git submodule update --recursive'.split()) | |||
|
397 | ||||
|
398 | class UpdateSubmodules(Command): | |||
|
399 | """Update git submodules | |||
|
400 | ||||
|
401 | IPython's external javascript dependencies live in a separate repo. | |||
|
402 | """ | |||
|
403 | description = "Update git submodules" | |||
|
404 | user_options = [] | |||
|
405 | ||||
|
406 | def initialize_options(self): | |||
|
407 | pass | |||
|
408 | ||||
|
409 | def finalize_options(self): | |||
|
410 | pass | |||
|
411 | ||||
|
412 | def run(self): | |||
|
413 | failure = False | |||
|
414 | try: | |||
|
415 | self.spawn('git submodule init'.split()) | |||
|
416 | self.spawn('git submodule update --recursive'.split()) | |||
|
417 | except Exception as e: | |||
|
418 | failure = e | |||
|
419 | print(e) | |||
|
420 | ||||
|
421 | if not check_for_submodules(): | |||
|
422 | print("submodules could not be checked out") | |||
|
423 | sys.exit(1) | |||
|
424 | ||||
|
425 | # re-scan package data after update | |||
|
426 | self.distribution.package_data = find_package_data() | |||
|
427 | ||||
|
428 | def git_prebuild(pkg_dir, build_cmd=build_py): | |||
|
429 | """Return extended build or sdist command class for recording commit | |||
373 |
|
430 | |||
374 | records git commit in IPython.utils._sysinfo.commit |
|
431 | records git commit in IPython.utils._sysinfo.commit | |
375 |
|
432 | |||
376 | for use in IPython.utils.sysinfo.sys_info() calls after installation. |
|
433 | for use in IPython.utils.sysinfo.sys_info() calls after installation. | |
|
434 | ||||
|
435 | Also ensures that submodules exist prior to running | |||
377 | """ |
|
436 | """ | |
378 |
|
437 | |||
379 | class MyBuildPy(build_cmd): |
|
438 | class MyBuildPy(build_cmd): | |
380 | ''' Subclass to write commit data into installation tree ''' |
|
439 | ''' Subclass to write commit data into installation tree ''' | |
381 | def run(self): |
|
440 | def run(self): | |
|
441 | if not check_for_submodules(): | |||
|
442 | print("submodules missing! Run `setup.py submodule` and try again") | |||
|
443 | sys.exit(1) | |||
|
444 | ||||
382 | build_cmd.run(self) |
|
445 | build_cmd.run(self) | |
383 | # this one will only fire for build commands |
|
446 | # this one will only fire for build commands | |
384 | if hasattr(self, 'build_lib'): |
|
447 | if hasattr(self, 'build_lib'): | |
@@ -416,3 +479,14 b' def record_commit_info(pkg_dir, build_cmd=build_py):' | |||||
416 | 'commit = "%s"\n' % repo_commit, |
|
479 | 'commit = "%s"\n' % repo_commit, | |
417 | ]) |
|
480 | ]) | |
418 | return MyBuildPy |
|
481 | return MyBuildPy | |
|
482 | ||||
|
483 | ||||
|
484 | def require_submodules(command): | |||
|
485 | """decorator for instructing a command to check for submodules before running""" | |||
|
486 | class DecoratedCommand(command): | |||
|
487 | def run(self): | |||
|
488 | if not check_for_submodules(): | |||
|
489 | print("submodules missing! Run `setup.py submodule` and try again") | |||
|
490 | sys.exit(1) | |||
|
491 | command.run(self) | |||
|
492 | return DecoratedCommand |
General Comments 0
You need to be logged in to leave comments.
Login now