diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-04-11 00:45:04 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-04-11 00:45:04 -0400 |
commit | c87de03d89ca07416bb2e2c252c7721313e5d9ec (patch) | |
tree | c6f7595991e1fbd6006263dfb2419240e08d329a /setuptools/__init__.py | |
parent | b118b5f25040715111699eff1345d1eb08457270 (diff) | |
download | external_python_setuptools-c87de03d89ca07416bb2e2c252c7721313e5d9ec.tar.gz external_python_setuptools-c87de03d89ca07416bb2e2c252c7721313e5d9ec.tar.bz2 external_python_setuptools-c87de03d89ca07416bb2e2c252c7721313e5d9ec.zip |
Exclude children of excluded parents when doing package discovery. Fixes #184.3.4.4
Diffstat (limited to 'setuptools/__init__.py')
-rw-r--r-- | setuptools/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 6f588962..8d46b6dd 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -50,6 +50,7 @@ class PackageFinder(object): explicitly excluded packages are removed from it. """ out = cls._find_packages_iter(convert_path(where)) + out = cls.require_parents(out) includes = cls._build_filter(*include) excludes = cls._build_filter('ez_setup', '*__pycache__', *exclude) out = filter(includes, out) @@ -57,6 +58,22 @@ class PackageFinder(object): return list(out) @staticmethod + def require_parents(packages): + """ + Exclude any apparent package that apparently doesn't include its + parent. + + For example, exclude 'foo.bar' if 'foo' is not present. + """ + found = [] + for pkg in packages: + base, sep, child = pkg.rpartition('.') + if base and base not in found: + continue + found.append(pkg) + yield pkg + + @staticmethod def _all_dirs(base_path): """ Return all dirs in base_path, relative to base_path |