Commit 29368600 authored by Xavier Thompson's avatar Xavier Thompson

[fix] Use only ws.find in install

Replace `pkg_resources.Environment(ws.entries).best_match(req, ws)`
with `ws.find(req)`.

The first already starts by calling `ws.find(req)` to attempt to find
an already activated dist in the working set, but if none is found it
then proceeds to scan through the entries of the environment - i.e.
the entries of the working set, `ws.entries` - to activate a dist at
these locations if one matches.

This is problematic if a dist from site-packages is in the working set
at this stage: this will consider site-packages over eggs installed in
.eggs, seemingly randomly depending on what dists are requested and
whether they are found in site-packages.

Also when calling `install(['zc.buildout'])` to resolve the dists of
buildout and its dependencies currently running there are no version
pins yet, so if `zc.buildout` comes from site-packages and specific
versions of its dependencies come from `.eggs` but other versions
exist in site-packages, then the dists from site-packages would be
found instead of the actually running dists from `.eggs`.
parent 7ec97f44
......@@ -790,10 +790,6 @@ class Installer(object):
requirements.reverse() # Set up the stack.
processed = {} # This is a set of processed requirements.
best = {} # This is a mapping of package name -> dist.
# Note that we don't use the existing environment, because we want
# to look for new eggs unless what we have is the best that
# matches the requirement.
env = pkg_resources.Environment(ws.entries)
while requirements:
# Process dependencies breadth-first.
......@@ -805,7 +801,15 @@ class Installer(object):
dist = best.get(req.key)
if dist is None:
try:
dist = env.best_match(req, ws)
# Note that we first attempt to find an already active dist
# in the working set. This will detect version conflicts.
# XXX We expressly avoid activating dists in the entries of
# the current working set: they might not reflect the order
# of the environment. This is not so bad when the versions
# are pinned, but when calling install(['zc.buildout']), it
# can come up with completely different dists than the ones
# currently running.
dist = ws.find(req)
except pkg_resources.VersionConflict as err:
logger.debug(
"Version conflict while processing requirement %s "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment