Commit 8807fcc3 authored by Jim Fulton's avatar Jim Fulton

Removed untested broken code with an optimization to avoid checking

for versions if the given requirement had an upper limit and we
already had the distribution whos version was the upper limit.

Added simpler tested code that checks for the simpler case that teh
requirement is for a specific version and we already have that
version.  In general, specifying upper limits other than a single
version is kind of dumb, so it's not worth optimizing for that case.
parent c737b9c8
......@@ -16,6 +16,15 @@ final soon.)
Change History
**************
1.0.0b28 (2007-07-05)
=====================
Bugs Fixed
----------
- When requiring a specific version, buildout looked for new versions
even if that single version was already installed.
1.0.0b27 (2007-06-20)
=====================
......
......@@ -35,7 +35,7 @@ open('doc.txt', 'w').write(long_description)
name = "zc.buildout"
setup(
name = name,
version = "1.0.0b27",
version = "1.0.0b28",
author = "Jim Fulton",
author_email = "jim@zope.com",
description = "System for managing development buildouts",
......
......@@ -180,47 +180,20 @@ class Installer:
# Environment.__getitem__.
return dists[0], None
# Find an upper limit in the specs, if there is one:
specs = [(pkg_resources.parse_version(v), op) for (op, v) in req.specs]
specs.sort()
maxv = None
greater = False
lastv = None
for v, op in specs:
if op == '==' and not greater:
maxv = v
elif op in ('>', '>=', '!='):
maxv = None
greater == True
elif op == '<':
maxv = None
greater == False
elif op == '<=':
maxv = v
greater == False
if v == lastv:
# Repeated versions values are undefined, so
# all bets are off
maxv = None
greater = True
else:
lastv = v
# Special common case, we have a specification for a single version:
specs = req.specs
if len(specs) == 1 and specs[0][0] == '==':
logger.debug('We have the distribution that satisfies %r.',
str(req))
return dists[0], None
best_we_have = dists[0] # Because dists are sorted from best to worst
# Check if we have the upper limit
if maxv is not None and best_we_have.version == maxv:
logger.debug('We have the best distribution that satisfies %r.',
str(req))
return best_we_have, None
# We have some installed distros. There might, theoretically, be
# newer ones. Let's find out which ones are available and see if
# any are newer. We only do this if we're willing to install
# something, which is only true if dest is not None:
if self._dest is not None:
best_available = self._obtain(req, source)
else:
......
......@@ -151,7 +151,7 @@ If we run the buildout with the versions section:
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = 0.6
Installing 'spam'.
We have the best distribution that satisfies 'spam==1'.
We have the distribution that satisfies 'spam==1'.
Uninstalling foo.
Installing foo.
recipe v1
......
......@@ -325,7 +325,7 @@ If we use the verbose switch, we can see where requirements are comning from:
We have a develop egg: samplez 1
Getting required 'demoneeded==1.1'
required by samplez 1.
We have the best distribution that satisfies 'demoneeded==1.1'.
We have the distribution that satisfies 'demoneeded==1.1'.
Getting required 'sampleb'
required by samplea 1.
We have a develop egg: sampleb 1
......
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