diff options
author | Luke Plant <L.Plant.98@cantab.net> | 2015-07-20 16:35:49 +0100 |
---|---|---|
committer | Luke Plant <L.Plant.98@cantab.net> | 2015-07-20 16:35:49 +0100 |
commit | d51ba2d7a8850a7fb56a6572b372626dd1cd3631 (patch) | |
tree | 66bf4a04399945208582e7f509ed2d655ba5b681 /setuptools | |
parent | e0beae7ae0bea46e4af3892bd4d9298d256d3205 (diff) | |
download | external_python_setuptools-d51ba2d7a8850a7fb56a6572b372626dd1cd3631.tar.gz external_python_setuptools-d51ba2d7a8850a7fb56a6572b372626dd1cd3631.tar.bz2 external_python_setuptools-d51ba2d7a8850a7fb56a6572b372626dd1cd3631.zip |
Big performance fix for find_packages by ignoring hidden dirs earlier
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/__init__.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 8188f125..f6536359 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -81,10 +81,20 @@ class PackageFinder(object): for dir in dirs: yield os.path.relpath(os.path.join(root, dir), base_path) + @staticmethod + def _suitable_dirs(base_path): + """ + Return all suitable package dirs in base_path, relative to base_path + """ + for root, dirs, files in os.walk(base_path, followlinks=True): + # Mutate dirs to trim the search: + dirs[:] = filterfalse(lambda n: '.' in n, dirs) + for dir in dirs: + yield os.path.relpath(os.path.join(root, dir), base_path) + @classmethod def _find_packages_iter(cls, base_path): - dirs = cls._all_dirs(base_path) - suitable = filterfalse(lambda n: '.' in n, dirs) + suitable = cls._suitable_dirs(base_path) return ( path.replace(os.path.sep, '.') for path in suitable |