diff options
| -rw-r--r-- | pkg_resources.py | 20 | ||||
| -rwxr-xr-x | setuptools.txt | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index af47d367..1a9b594c 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -460,8 +460,6 @@ class WorkingSet(object): already-installed distribution; it should return a ``Distribution`` or ``None``. """ - if env is None: - env = AvailableDistributions(self.entries) requirements = list(requirements)[::-1] # set up the stack processed = {} # set of processed requirements @@ -477,6 +475,8 @@ class WorkingSet(object): dist = best.get(req.key) if dist is None: # Find the best distribution and add it to the map + if env is None: + env = AvailableDistributions(self.entries) dist = best[req.key] = env.best_match(req, self, installer) if dist is None: raise DistributionNotFound(req) # XXX put more info here @@ -1232,8 +1232,6 @@ class ImpWrapper: """PEP 302 Importer that wraps Python's "normal" import algorithm""" def __init__(self, path=None): - if path is not None and not os.path.isdir(path): - raise ImportError self.path = path def find_module(self, fullname, path=None): @@ -1269,6 +1267,8 @@ class ImpLoader: return mod + + def get_importer(path_item): """Retrieve a PEP 302 "importer" for the given path item @@ -1357,9 +1357,8 @@ register_finder(object,find_nothing) def find_on_path(importer, path_item, only=False): """Yield distributions accessible on a sys.path directory""" - if not os.path.exists(path_item): - return path_item = normalize_path(path_item) + if os.path.isdir(path_item): if path_item.lower().endswith('.egg'): # unpacked egg @@ -1370,10 +1369,10 @@ def find_on_path(importer, path_item, only=False): ) else: # scan for .egg and .egg-info in directory - for entry in os.listdir(path_item): - fullpath = os.path.join(path_item, entry) + for entry in os.listdir(path_item): lower = entry.lower() if lower.endswith('.egg-info'): + fullpath = os.path.join(path_item, entry) if os.path.isdir(fullpath): # development egg metadata = PathMetadata(path_item, fullpath) @@ -1382,16 +1381,17 @@ def find_on_path(importer, path_item, only=False): path_item, metadata, project_name=dist_name ) elif not only and lower.endswith('.egg'): - for dist in find_distributions(fullpath): + for dist in find_distributions(os.path.join(path_item, entry)): yield dist elif not only and lower.endswith('.egg-link'): - for line in file(fullpath): + for line in file(os.path.join(path_item, entry)): if not line.strip(): continue for item in find_distributions(line.rstrip()): yield item register_finder(ImpWrapper,find_on_path) + _namespace_handlers = {} _namespace_packages = {} diff --git a/setuptools.txt b/setuptools.txt index b9911703..1c466d06 100755 --- a/setuptools.txt +++ b/setuptools.txt @@ -1597,6 +1597,10 @@ Release Notes/Change History containing ``setup.py``, not the highest revision number in the project. * Added ``eager_resources`` setup argument + + * Enhanced performance of ``require()`` and related operations when all + requirements are already in the working set, and enhanced performance of + directory scanning for distributions. * Fixed some problems using ``pkg_resources`` w/PEP 302 loaders other than ``zipimport``, and the previously-broken "eager resource" support. |
