Commit 83877a21 authored by Alex Clark ☺'s avatar Alex Clark ☺

Merge pull request #199 from reinout/reinout-fix-for-193

Fix for buildout 2.2.3 upgrade/downgrade problems
parents 2226a2ea aed82c07
Change History Change History
************** **************
2.2. (unreleased)
==================
- Fix for #198: buildout 2.2.3 caused a version conflict when bootstrapping a
buildout with a version pinned to an earlier one. Same version conflict
could occur with system-wide installed packages that were newer than the
pinned version.
[reinout]
2.2.3 (2014-10-30) 2.2.3 (2014-10-30)
================== ==================
......
...@@ -635,39 +635,49 @@ class Installer: ...@@ -635,39 +635,49 @@ class Installer:
# zc.buildout.tests). # zc.buildout.tests).
requirements.reverse() # Set up the stack. requirements.reverse() # Set up the stack.
processed = {} # This is a set of processed requirements. processed = {} # This is a set of processed requirements.
best = {} # This is a mapping of key -> dist. best = {} # This is a mapping of package name -> dist.
# Note that we don't use the existing environment, because we want # 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 # to look for new eggs unless what we have is the best that
# matches the requirement. # matches the requirement.
env = pkg_resources.Environment(ws.entries) env = pkg_resources.Environment(ws.entries)
while requirements: while requirements:
# Process dependencies breadth-first. # Process dependencies breadth-first.
req = self._constrain(requirements.pop(0)) current_requirement = requirements.pop(0)
req = self._constrain(current_requirement)
if req in processed: if req in processed:
# Ignore cyclic or redundant dependencies. # Ignore cyclic or redundant dependencies.
continue continue
dist = best.get(req.key) dist = best.get(req.key)
if dist is None: if dist is None:
# Find the best distribution and add it to the map. try:
dist = ws.by_key.get(req.key) dist = env.best_match(req, ws)
if dist is None: except pkg_resources.VersionConflict as err:
try: logger.debug(
dist = best[req.key] = env.best_match(req, ws) "Version conflict while processing requirement %s "
except pkg_resources.VersionConflict as err: "(constrained to %s)",
current_requirement, req)
# When bootstrapping zc.buildout, we might be doing it
# with a different version than the one we specified in
# our versions list. Reason: the bootstrap grabs the
# latest buildout. Same with setuptools.
# So ignore the version conflict for those two packages.
if req.key not in ['zc.buildout', 'setuptools']:
raise VersionConflict(err, ws) raise VersionConflict(err, ws)
if dist is None: if dist is None:
if dest: if dest:
logger.debug('Getting required %r', str(req)) logger.debug('Getting required %r', str(req))
else: else:
logger.debug('Adding required %r', str(req)) logger.debug('Adding required %r', str(req))
_log_requirement(ws, req) _log_requirement(ws, req)
for dist in self._get_dist(req, ws,): for dist in self._get_dist(req, ws,):
ws.add(dist) ws.add(dist)
self._maybe_add_setuptools(ws, dist) self._maybe_add_setuptools(ws, dist)
if dist not in req: if dist not in req:
# Oops, the "best" so far conflicts with a dependency. # Oops, the "best" so far conflicts with a dependency.
raise VersionConflict( raise VersionConflict(
pkg_resources.VersionConflict(dist, req), ws) pkg_resources.VersionConflict(dist, req), ws)
best[req.key] = dist
requirements.extend(dist.requires(req.extras)[::-1]) requirements.extend(dist.requires(req.extras)[::-1])
processed[req] = True processed[req] = True
return ws return ws
......
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