diff options
author | PJ Eby <distutils-sig@python.org> | 2005-12-15 02:45:03 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-12-15 02:45:03 +0000 |
commit | d989230127c6e16c505096f6150db977e61478b3 (patch) | |
tree | ed87402243ca1a75876e7a640bd983666ac2025c /setuptools/command/build_py.py | |
parent | 1b77dd8e7845b5ac38fc7367796290dd65b8c531 (diff) | |
download | external_python_setuptools-d989230127c6e16c505096f6150db977e61478b3.tar.gz external_python_setuptools-d989230127c6e16c505096f6150db977e61478b3.tar.bz2 external_python_setuptools-d989230127c6e16c505096f6150db977e61478b3.zip |
Added the ``exclude_package_data`` keyword to ``setup()``, allowing you
to trim back files included via the ``package_data`` and
``include_package_data`` options.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041693
Diffstat (limited to 'setuptools/command/build_py.py')
-rw-r--r-- | setuptools/command/build_py.py | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 35b9c57e..4d779f57 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -1,4 +1,4 @@ -import os.path, sys +import os.path, sys, fnmatch from distutils.command.build_py import build_py as _build_py from distutils.util import convert_path from glob import glob @@ -12,10 +12,10 @@ class build_py(_build_py): Also, this version of the 'build_py' command allows you to specify both 'py_modules' and 'packages' in the same setup operation. """ - def finalize_options(self): _build_py.finalize_options(self) self.package_data = self.distribution.package_data + self.exclude_package_data = self.distribution.exclude_package_data or {} if 'data_files' in self.__dict__: del self.__dict__['data_files'] def run(self): @@ -68,7 +68,7 @@ class build_py(_build_py): for pattern in globs: # Each pattern has to be converted to a platform-specific path files.extend(glob(os.path.join(src_dir, convert_path(pattern)))) - return files + return self.exclude_data_files(package, src_dir, files) def build_package_data(self): """Copy data files into build directory""" @@ -162,3 +162,44 @@ class build_py(_build_py): + def exclude_data_files(self, package, src_dir, files): + """Filter filenames for package's data files in 'src_dir'""" + globs = (self.exclude_package_data.get('', []) + + self.exclude_package_data.get(package, [])) + bad = [] + for pattern in globs: + bad.extend( + fnmatch.filter( + files, os.path.join(src_dir, convert_path(pattern)) + ) + ) + bad = dict.fromkeys(bad) + return [f for f in files if f not in bad] + + + + + + + + + + + + + + + + + + + + + + + + + + + + |