Commit b5edac6f authored by jim's avatar jim

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.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@77454 62d5b8a3-27da-0310-9561-8e5933582275
parent bb0dd1e7
...@@ -16,6 +16,15 @@ final soon.) ...@@ -16,6 +16,15 @@ final soon.)
Change History 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) 1.0.0b27 (2007-06-20)
===================== =====================
......
...@@ -35,7 +35,7 @@ open('doc.txt', 'w').write(long_description) ...@@ -35,7 +35,7 @@ open('doc.txt', 'w').write(long_description)
name = "zc.buildout" name = "zc.buildout"
setup( setup(
name = name, name = name,
version = "1.0.0b27", version = "1.0.0b28",
author = "Jim Fulton", author = "Jim Fulton",
author_email = "jim@zope.com", author_email = "jim@zope.com",
description = "System for managing development buildouts", description = "System for managing development buildouts",
......
...@@ -180,46 +180,19 @@ class Installer: ...@@ -180,46 +180,19 @@ class Installer:
# Environment.__getitem__. # Environment.__getitem__.
return dists[0], None return dists[0], None
# Find an upper limit in the specs, if there is one: # Special common case, we have a specification for a single version:
specs = [(pkg_resources.parse_version(v), op) for (op, v) in req.specs] specs = req.specs
specs.sort() if len(specs) == 1 and specs[0][0] == '==':
maxv = None logger.debug('We have the distribution that satisfies %r.',
greater = False str(req))
lastv = None return dists[0], 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
best_we_have = dists[0] # Because dists are sorted from best to worst 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 # We have some installed distros. There might, theoretically, be
# newer ones. Let's find out which ones are available and see if # 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 # any are newer. We only do this if we're willing to install
# something, which is only true if dest is not None: # something, which is only true if dest is not None:
if self._dest is not None: if self._dest is not None:
best_available = self._obtain(req, source) best_available = self._obtain(req, source)
......
...@@ -151,7 +151,7 @@ If we run the buildout with the versions section: ...@@ -151,7 +151,7 @@ If we run the buildout with the versions section:
We have the best distribution that satisfies 'setuptools'. We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = 0.6 Picked: setuptools = 0.6
Installing 'spam'. Installing 'spam'.
We have the best distribution that satisfies 'spam==1'. We have the distribution that satisfies 'spam==1'.
Uninstalling foo. Uninstalling foo.
Installing foo. Installing foo.
recipe v1 recipe v1
......
...@@ -325,7 +325,7 @@ If we use the verbose switch, we can see where requirements are comning from: ...@@ -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 We have a develop egg: samplez 1
Getting required 'demoneeded==1.1' Getting required 'demoneeded==1.1'
required by samplez 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' Getting required 'sampleb'
required by samplea 1. required by samplea 1.
We have a develop egg: sampleb 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