summaryrefslogtreecommitdiff
path: root/setuptools/__init__.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-03-22 09:05:56 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-03-22 09:05:56 -0400
commit17c19bd6ef3c63e112f82f3e81c1d863fd5074e5 (patch)
tree5875567173dc4a82b24e0c48a02299f0c9042a78 /setuptools/__init__.py
parent4545777795b8cd7abecc5ff59dcbacd957237f84 (diff)
downloadpython-setuptools-git-17c19bd6ef3c63e112f82f3e81c1d863fd5074e5.tar.gz
Extracted directory detection and presence of '.' in name.
Diffstat (limited to 'setuptools/__init__.py')
-rw-r--r--setuptools/__init__.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py
index a4c46222..2e9c14f4 100644
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -50,15 +50,13 @@ def find_packages(where='.', exclude=(), include=('*',)):
stack=[(convert_path(where), '')]
while stack:
where,prefix = stack.pop(0)
- for name in os.listdir(where):
+ dirs = _dirs(where)
+ suitable = filterfalse(lambda n: '.' in n, dirs)
+ for name in suitable:
fn = os.path.join(where,name)
looks_like_package = (
- '.' not in name
- and os.path.isdir(fn)
- and (
- os.path.isfile(os.path.join(fn, '__init__.py'))
- or sys.version_info[:2] >= (3, 3) # PEP 420
- )
+ os.path.isfile(os.path.join(fn, '__init__.py'))
+ or sys.version_info[:2] >= (3, 3) # PEP 420
)
if looks_like_package:
pkg_name = prefix + name
@@ -70,6 +68,16 @@ def find_packages(where='.', exclude=(), include=('*',)):
out = filterfalse(excludes, out)
return list(out)
+def _dirs(target):
+ """
+ Return all directories in target
+ """
+ return (
+ fn
+ for fn in os.listdir(target)
+ if os.path.isdir(os.path.join(target, fn))
+ )
+
def _build_filter(*patterns):
"""
Given a list of patterns, return a callable that will be true only if