diff options
-rw-r--r-- | setuptools/__init__.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index f12c8dd6..33b05815 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -53,22 +53,24 @@ def find_packages(where='.', exclude=(), include=('*',)): dirs = _dirs(where) suitable = filterfalse(lambda n: '.' in n, dirs) paths = (os.path.join(where, name) for name in suitable) - for path in paths: + packages = filter(_looks_like_package, paths) + for path in packages: name = os.path.basename(path) - looks_like_package = ( - os.path.isfile(os.path.join(path, '__init__.py')) - or sys.version_info[:2] >= (3, 3) # PEP 420 - ) - if looks_like_package: - pkg_name = prefix + name - out.append(pkg_name) - stack.append((path, pkg_name + '.')) + pkg_name = prefix + name + out.append(pkg_name) + stack.append((path, pkg_name + '.')) includes = _build_filter(*include) excludes = _build_filter('ez_setup', '*__pycache__', *exclude) out = filter(includes, out) out = filterfalse(excludes, out) return list(out) +def _looks_like_package(path): + return ( + os.path.isfile(os.path.join(path, '__init__.py')) + or sys.version_info[:2] >= (3, 3) # PEP 420 + ) + def _dirs(target): """ Return all directories in target |