From c79134f2d9b4ddaa746cb874532651a2d8de331c Mon Sep 17 00:00:00 2001 From: MinRK Date: Wed, 5 Feb 2014 21:36:49 -0800 Subject: [PATCH] only validate package_data when it might be used closes #5046 --- setup.py | 11 +++++++++++ setupbase.py | 8 +++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 587a6e309..ac7bde9fd 100755 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ from setupbase import ( setup_args, find_packages, find_package_data, + check_package_data, find_entry_points, build_scripts_entrypt, find_data_files, @@ -191,12 +192,22 @@ if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): packages = find_packages() package_data = find_package_data() + data_files = find_data_files() setup_args['packages'] = packages setup_args['package_data'] = package_data setup_args['data_files'] = data_files +def maybe_check_package_data(): + for should_check in ('bdist', 'sdist', 'build', 'install'): + for arg in sys.argv: + if arg.startswith(should_check): + check_package_data(package_data) + return + +maybe_check_package_data() + #--------------------------------------------------------------------------- # custom distutils commands #--------------------------------------------------------------------------- diff --git a/setupbase.py b/setupbase.py index c15e9abcf..460a671f2 100644 --- a/setupbase.py +++ b/setupbase.py @@ -188,7 +188,11 @@ def find_package_data(): 'IPython.nbformat' : ['tests/*.ipynb'] } - # verify that package_data makes sense + return package_data + +def check_package_data(package_data): + """verify that package_data globs make sense""" + print("checking package data") for pkg, data in package_data.items(): pkg_root = pjoin(*pkg.split('.')) for d in data: @@ -198,8 +202,6 @@ def find_package_data(): else: assert os.path.exists(path), "Missing package data: %s" % path - return package_data - #--------------------------------------------------------------------------- # Find data files