diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-03-22 09:12:33 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-03-22 09:12:33 -0400 |
commit | 50f98edc5d47d11a93a9e28fe2fd5577ca36320b (patch) | |
tree | c55be8e8f1d0ef88330a9dd1ec6a98080bab87f1 | |
parent | 8679c5facc30a558613c137c5ec3305d320134b6 (diff) | |
download | external_python_setuptools-50f98edc5d47d11a93a9e28fe2fd5577ca36320b.tar.gz external_python_setuptools-50f98edc5d47d11a93a9e28fe2fd5577ca36320b.tar.bz2 external_python_setuptools-50f98edc5d47d11a93a9e28fe2fd5577ca36320b.zip |
Extract _looks_like_package
-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 |