Commit 58d44373 authored by Peter Uittenbroek's avatar Peter Uittenbroek

Introduce improved easy_install.py Install.install function. Originally...

Introduce improved easy_install.py Install.install function. Originally commited in 98b7c55cb8b8e39e4835b5dd4223fda55f519890
parent b208fe6f
...@@ -609,9 +609,9 @@ class Installer: ...@@ -609,9 +609,9 @@ class Installer:
logger.debug('Installing %s.', repr(specs)[1:-1]) logger.debug('Installing %s.', repr(specs)[1:-1])
path = self._path path = self._path
dest = self._dest destination = self._dest
if dest is not None and dest not in path: if destination is not None and destination not in path:
path.insert(0, dest) path.insert(0, destination)
requirements = [self._constrain(pkg_resources.Requirement.parse(spec)) requirements = [self._constrain(pkg_resources.Requirement.parse(spec))
for spec in specs] for spec in specs]
...@@ -629,35 +629,51 @@ class Installer: ...@@ -629,35 +629,51 @@ class Installer:
self._maybe_add_setuptools(ws, dist) self._maybe_add_setuptools(ws, dist)
# OK, we have the requested distributions and they're in the working # OK, we have the requested distributions and they're in the working
# set, but they may have unmet requirements. We'll simply keep # set, but they may have unmet requirements. We'll resolve these
# trying to resolve requirements, adding missing requirements as they # requirements. This is code modified from
# are reported. # pkg_resources.WorkingSet.resolve. We can't reuse that code directly
# # because we have to constrain our requirements (see
# Note that we don't pass in the environment, because we want # versions_section_ignored_for_dependency_in_favor_of_site_packages in
# zc.buildout.tests).
requirements.reverse() # Set up the stack.
processed = {} # This is a set of processed requirements.
best = {} # This is a mapping of key -> 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 # to look for new eggs unless what we have is the best that
# matches the requirement. # matches the requirement.
while 1: env = pkg_resources.Environment(ws.entries)
try: while requirements:
ws.resolve(requirements) # Process dependencies breadth-first.
except pkg_resources.DistributionNotFound: req = self._constrain(requirements.pop(0))
err = sys.exc_info()[1] if req in processed:
[requirement] = err.args # Ignore cyclic or redundant dependencies.
requirement = self._constrain(requirement) continue
if dest: dist = best.get(req.key)
logger.debug('Getting required %r', str(requirement)) if dist is None:
else: # Find the best distribution and add it to the map.
logger.debug('Adding required %r', str(requirement)) dist = ws.by_key.get(req.key)
_log_requirement(ws, requirement) if dist is None:
try:
for dist in self._get_dist(requirement, ws): dist = best[req.key] = env.best_match(req, ws)
ws.add(dist) except pkg_resources.VersionConflict, err:
self._maybe_add_setuptools(ws, dist) raise VersionConflict(err, ws)
except pkg_resources.VersionConflict: if dist is None:
err = sys.exc_info()[1] if destination:
raise VersionConflict(err, ws) logger.debug('Getting required %r', str(req))
else: else:
break logger.debug('Adding required %r', str(req))
_log_requirement(ws, req)
for dist in self._get_dist(req, ws,):
ws.add(dist)
self._maybe_add_setuptools(ws, dist)
if dist not in req:
# Oops, the "best" so far conflicts with a dependency.
raise VersionConflict(
pkg_resources.VersionConflict(dist, req), ws)
requirements.extend(dist.requires(req.extras)[::-1])
processed[req] = True
# if dist.location in self._site_packages:
# logger.debug('Egg from site-packages: %s', dist)
return ws return ws
def build(self, spec, build_ext): def build(self, spec, build_ext):
......
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