summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py51
1 files changed, 46 insertions, 5 deletions
diff --git a/setup.py b/setup.py
index 2fb0a5eae..12eb29093 100755
--- a/setup.py
+++ b/setup.py
@@ -151,6 +151,44 @@ 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 generate_cython():
+ cwd = os.path.abspath(os.path.dirname(__file__))
+ print("Cythonizing sources")
+ p = subprocess.call([sys.executable,
+ os.path.join(cwd, 'tools', 'cythonize.py'),
+ 'numpy/random'],
+ cwd=cwd)
+ if p != 0:
+ raise RuntimeError("Running cythonize failed!")
def setup_package():
src_path = os.path.dirname(os.path.abspath(sys.argv[0]))
@@ -174,6 +212,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
@@ -189,13 +228,15 @@ def setup_package():
FULLVERSION, GIT_REVISION = get_version_info()
metadata['version'] = FULLVERSION
- elif len(sys.argv) >= 2 and sys.argv[1] == 'bdist_wheel':
- # bdist_wheel needs setuptools
- import setuptools
- from numpy.distutils.core import setup
- metadata['configuration'] = configuration
else:
+ if len(sys.argv) >= 2 and sys.argv[1] == 'bdist_wheel':
+ # bdist_wheel needs setuptools
+ import setuptools
from numpy.distutils.core import setup
+ cwd = os.path.abspath(os.path.dirname(__file__))
+ if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
+ # Generate Cython sources, unless building from source release
+ generate_cython()
metadata['configuration'] = configuration
try: