Commit c87de03d authored by Jason R. Coombs's avatar Jason R. Coombs

Exclude children of excluded parents when doing package discovery. Fixes #184.

parent b118b5f2
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
CHANGES CHANGES
======= =======
-----
3.4.4
-----
* Issue #184: Correct failure where find_package over-matched packages
when directory traversal isn't short-circuited.
----- -----
3.4.3 3.4.3
----- -----
......
...@@ -50,12 +50,29 @@ class PackageFinder(object): ...@@ -50,12 +50,29 @@ class PackageFinder(object):
explicitly excluded packages are removed from it. explicitly excluded packages are removed from it.
""" """
out = cls._find_packages_iter(convert_path(where)) out = cls._find_packages_iter(convert_path(where))
out = cls.require_parents(out)
includes = cls._build_filter(*include) includes = cls._build_filter(*include)
excludes = cls._build_filter('ez_setup', '*__pycache__', *exclude) excludes = cls._build_filter('ez_setup', '*__pycache__', *exclude)
out = filter(includes, out) out = filter(includes, out)
out = filterfalse(excludes, out) out = filterfalse(excludes, out)
return list(out) 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 @staticmethod
def _all_dirs(base_path): def _all_dirs(base_path):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment