##// END OF EJS Templates
use utils/submodule in setup.py...
MinRK -
Show More
@@ -68,7 +68,7 b' from setupbase import ('
68 68 find_data_files,
69 69 check_for_dependencies,
70 70 git_prebuild,
71 check_for_submodules,
71 check_submodule_status,
72 72 update_submodules,
73 73 require_submodules,
74 74 UpdateSubmodules,
@@ -112,21 +112,37 b" if os_name == 'windows' and 'sdist' in sys.argv:"
112 112 #-------------------------------------------------------------------------------
113 113 # Make sure we aren't trying to run without submodules
114 114 #-------------------------------------------------------------------------------
115 here = os.path.abspath(os.path.dirname(__file__))
115 116
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.
117 def require_clean_submodules():
118 """Check on git submodules before distutils can do anything
119
120 Since distutils cannot be trusted to update the tree
121 after everything has been set in motion,
122 this is not a distutils command.
121 123 """
122 124 # don't do anything if nothing is actually supposed to happen
123 for do_nothing in ('-h', '--help', '--help-commands', 'clean'):
125 for do_nothing in ('-h', '--help', '--help-commands', 'clean', 'submodule'):
124 126 if do_nothing in sys.argv:
125 127 return
126 if not check_for_submodules():
127 update_submodules()
128 128
129 ensure_submodules_exist()
129 status = check_submodule_status(here)
130
131 if status == "missing":
132 print("checking out submodules for the first time")
133 update_submodules(here)
134 elif status == "unclean":
135 print('\n'.join([
136 "Cannot build / install IPython with unclean submodules",
137 "Please update submodules with",
138 " python setup.py submodule",
139 "or",
140 " git submodule update",
141 "or commit any submodule changes you have made."
142 ]))
143 sys.exit(1)
144
145 require_clean_submodules()
130 146
131 147 #-------------------------------------------------------------------------------
132 148 # Things related to the IPython documentation
@@ -373,27 +373,10 b' def check_for_dependencies():'
373 373 # VCS related
374 374 #---------------------------------------------------------------------------
375 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', 'components')
385 ]
386 for submodule in submodules:
387 if not os.path.exists(submodule):
388 return False
389 return True
376 here = os.path.abspath(os.path.dirname(__file__))
390 377
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())
378 # utils.submodule has checks for submodule status
379 execfile(pjoin('IPython','utils','submodule.py'), globals())
397 380
398 381 class UpdateSubmodules(Command):
399 382 """Update git submodules
@@ -418,12 +401,10 b' class UpdateSubmodules(Command):'
418 401 failure = e
419 402 print(e)
420 403
421 if not check_for_submodules():
404 if not check_submodule_status(here) == 'clean':
422 405 print("submodules could not be checked out")
423 406 sys.exit(1)
424
425 # re-scan package data after update
426 self.distribution.package_data = find_package_data()
407
427 408
428 409 def git_prebuild(pkg_dir, build_cmd=build_py):
429 410 """Return extended build or sdist command class for recording commit
@@ -438,10 +419,6 b' def git_prebuild(pkg_dir, build_cmd=build_py):'
438 419 class MyBuildPy(build_cmd):
439 420 ''' Subclass to write commit data into installation tree '''
440 421 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
445 422 build_cmd.run(self)
446 423 # this one will only fire for build commands
447 424 if hasattr(self, 'build_lib'):
@@ -478,14 +455,14 b' def git_prebuild(pkg_dir, build_cmd=build_py):'
478 455 '# GENERATED BY setup.py\n',
479 456 'commit = "%s"\n' % repo_commit,
480 457 ])
481 return MyBuildPy
458 return require_submodules(MyBuildPy)
482 459
483 460
484 461 def require_submodules(command):
485 462 """decorator for instructing a command to check for submodules before running"""
486 463 class DecoratedCommand(command):
487 464 def run(self):
488 if not check_for_submodules():
465 if not check_submodule_status(here) == 'clean':
489 466 print("submodules missing! Run `setup.py submodule` and try again")
490 467 sys.exit(1)
491 468 command.run(self)
General Comments 0
You need to be logged in to leave comments. Login now