only validate package_data when it might be used

closes #5046
This commit is contained in:
MinRK 2014-02-05 21:36:49 -08:00
parent 2b248d65b0
commit c79134f2d9
2 changed files with 16 additions and 3 deletions

View File

@ -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
#---------------------------------------------------------------------------

View File

@ -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