summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-01-29 22:59:19 +0100
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-01-29 23:22:20 +0100
commit4cd72742079c6eba4ec0803975c43b779545b537 (patch)
tree06c9616736b329d0b4b824c16107cc14e4e24479 /setup.py
parentc159cb078b4069ba8fdeddedb0ee7f01dd0656d2 (diff)
downloadnumpy-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-xsetup.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 2fb0a5eae..0d367c1d5 100755
--- a/setup.py
+++ b/setup.py
@@ -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