diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-01-29 22:59:19 +0100 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-01-29 23:22:20 +0100 |
commit | 4cd72742079c6eba4ec0803975c43b779545b537 (patch) | |
tree | 06c9616736b329d0b4b824c16107cc14e4e24479 /setup.py | |
parent | c159cb078b4069ba8fdeddedb0ee7f01dd0656d2 (diff) | |
download | numpy-4cd72742079c6eba4ec0803975c43b779545b537.tar.gz |
BLD: check submodules on sdist
prevents broken source distributions due to not up to date submodules.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -151,6 +151,34 @@ def configuration(parent_package='',top_path=None): return config +def check_submodules(): + """ verify that the submodules are checked out and clean + use `git submodule update --init`; on failure + """ + if not os.path.exists('.git'): + return + with open('.gitmodules') as f: + for l in f: + if 'path' in l: + p = l.split('=')[-1].strip() + if not os.path.exists(p): + raise ValueError('Submodule %s missing' % p) + + + proc = subprocess.Popen(['git', 'submodule', 'status'], + stdout=subprocess.PIPE) + status, _ = proc.communicate() + status = status.decode("ascii", "replace") + for line in status.splitlines(): + if line.startswith('-') or line.startswith('+'): + raise ValueError('Submodule not clean: %s' % line) + +from distutils.command.sdist import sdist +class sdist_checked(sdist): + """ check submodules on sdist to prevent incomplete tarballs """ + def run(self): + check_submodules() + sdist.run(self) def setup_package(): src_path = os.path.dirname(os.path.abspath(sys.argv[0])) @@ -174,6 +202,7 @@ def setup_package(): classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f], platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"], test_suite='nose.collector', + cmdclass={"sdist": sdist_checked}, ) # Run build |