Commit 47645243 authored by Jim Fulton's avatar Jim Fulton

cherry-picked d3c78d5c

Make sure (???) buildout doesn't downgrade due to defer-final
parent ecac6b62
......@@ -277,8 +277,11 @@ class Buildout(UserDict.DictMixin):
versions = options.get('versions')
if versions:
zc.buildout.easy_install.default_versions(dict(self[versions]))
versions = dict(self[versions])
zc.buildout.easy_install.default_versions(versions)
else:
versions = {}
self.versions = versions
self.offline = options.get_bool('offline')
if self.offline:
......@@ -881,13 +884,22 @@ class Buildout(UserDict.DictMixin):
if not self.newest:
return
options = self['buildout']
specs = ['zc.buildout']
if zc.buildout.easy_install.is_distribute:
specs.append('distribute')
else:
specs.append('setuptools')
# Prevent downgrading due to prefer-final:
options = self['buildout']
if not ('zc.buildout-version' in options
or
'zc.buildout' in self.versions):
v = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('zc.buildout')
).version
options['zc.buildout-version'] = '>=' + v
ws = zc.buildout.easy_install.install(
[
(spec + ' ' + options.get(spec+'-version', '')).strip()
......
......@@ -2259,7 +2259,7 @@ database is shown.
... """)
>>> print system(buildout+' -vv'), # doctest: +NORMALIZE_WHITESPACE
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.9a1', 'setuptools'.
We have a develop egg: zc.buildout X.X.
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = V.V
......@@ -2293,6 +2293,7 @@ database is shown.
unzip = false
use-dependency-links = true
verbosity = 20
zc.buildout-version = >=1.9a1
<BLANKLINE>
All of these options can be overridden by configuration files or by
......
......@@ -124,7 +124,7 @@ about versions used. If we run the buildout in verbose mode without
specifying a versions section:
>>> print system(buildout+' buildout:versions= -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = 0.6
......@@ -146,7 +146,7 @@ that we can fix them in a versions section.
If we run the buildout with the versions section:
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = 0.6
......
......@@ -321,7 +321,7 @@ if we hadn't required sampley ourselves:
If we use the verbose switch, we can see where requirements are coming from:
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = 0.6
......@@ -420,7 +420,7 @@ indicate the eggs from site-packages that have been selected. You'll see
we have two: demo 0.3 and demoneeded 1.1.
>>> print system(buildout+" -v"),
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.9.0', 'setuptools'.
We have a develop egg: zc.buildout V
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = V
......@@ -616,7 +616,7 @@ def create_sections_on_command_line():
... ''')
>>> print system(buildout + ' foo:bar=1 -vv'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
...
[foo]
bar = 1
......@@ -2801,7 +2801,7 @@ def dealing_with_extremely_insane_dependencies():
However, if we run in verbose mode, we can see why packages were included:
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.9.0', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'setuptools'.
Picked: setuptools = 0.6
......@@ -3092,7 +3092,7 @@ The default is prefer-final = false:
... ''' % globals())
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
...
Picked: demo = 0.4c1
...
......@@ -3114,7 +3114,7 @@ We get the same behavior if we add prefer-final = false
... ''' % globals())
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
...
Picked: demo = 0.4c1
...
......@@ -3136,7 +3136,7 @@ distributions:
... ''' % globals())
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing 'zc.buildout', 'setuptools'.
Installing 'zc.buildout >=1.99', 'setuptools'.
...
Picked: demo = 0.3
...
......@@ -3160,6 +3160,50 @@ We get an error if we specify anything but true or false:
While:
Initializing.
Error: Invalid value for prefer-final option: no
"""
def wont_downgrade_due_to_prefer_final():
r"""
If we install a non-final buildout version, we don't want to
downgrade just bcause we prefer-final. If a buildout version
isn't specified, either through buildout-version or a versions
entry, then buildout-version gets set to >=CURRENT_VERSION.
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... ''')
>>> [v] = [l.split('=', 1)[1].strip()
... for l in system(buildout+' -vv').split('\n')
... if l.startswith('zc.buildout-version = ')]
>>> v == '>=' + pkg_resources.working_set.find(
... pkg_resources.Requirement.parse('zc.buildout')
... ).version
True
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... zc.buildout-version = >.1
... ''')
>>> [l.split('=', 1)[1].strip()
... for l in system(buildout+' -vv').split('\n')
... if l.startswith('zc.buildout-version =')]
['>.1']
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... versions = versions
... [versions]
... zc.buildout = 43
... ''')
>>> print system(buildout+' -v'), # doctest: +ELLIPSIS
Installing...
Error: Couldn't find a distribution for 'zc.buildout==43'.
"""
......@@ -3975,6 +4019,8 @@ def test_suite():
zc.buildout.testing.normalize_egg_py,
zc.buildout.tests.hide_distribute_additions,
hide_zip_safe_message,
(re.compile(r'zc.buildout-version = >=\S+'), ''),
(re.compile(r"Installing 'zc.buildout >=\S+"), ''),
(re.compile('__buildout_signature__ = recipes-\S+'),
'__buildout_signature__ = recipes-SSSSSSSSSSS'),
(re.compile('executable = [\S ]+python\S*', re.I),
......@@ -4010,6 +4056,9 @@ def test_suite():
zc.buildout.testing.normalize_egg_py,
zc.buildout.tests.hide_distribute_additions,
hide_zip_safe_message,
(re.compile(r"Installing 'zc.buildout >=\S+"), ''),
(re.compile(r"Getting distribution for 'zc.buildout >=\S+"),
''),
(re.compile('__buildout_signature__ = recipes-\S+'),
'__buildout_signature__ = recipes-SSSSSSSSSSS'),
(re.compile('executable = [\S ]+python\S*', re.I),
......@@ -4058,6 +4107,9 @@ def test_suite():
zc.buildout.testing.normalize_egg_py,
normalize_bang,
zc.buildout.tests.hide_distribute_additions,
(re.compile(r"Installing 'zc.buildout >=\S+"), ''),
(re.compile(r"Getting distribution for 'zc.buildout>=\S+"),
''),
(re.compile('99[.]99'), 'NINETYNINE.NINETYNINE'),
(re.compile('(zc.buildout|setuptools)-\d+[.]\d+\S*'
'-py\d.\d.egg'),
......@@ -4133,6 +4185,8 @@ def test_suite():
zc.buildout.testing.normalize_egg_py,
zc.buildout.tests.hide_distribute_additions,
hide_first_index_page_message,
(re.compile(r"Installing 'zc.buildout >=\S+"), 'Installing '),
(re.compile(r'^(\w+\.)*(Missing\w+: )'), '\2'),
(re.compile("buildout: Running \S*setup.py"),
'buildout: Running setup.py'),
(re.compile('(setuptools|distribute)-\S+-'),
......@@ -4151,7 +4205,8 @@ def test_suite():
'-q develop -mxN -d /sample-buildout/develop-eggs'
),
(re.compile(r'^[*]...'), '...'),
# for bug_92891_bootstrap_crashes_with_egg_recipe_in_buildout_section
# for 92891
# bootstrap_crashes_with_egg_recipe_in_buildout_section
(re.compile(r"Unused options for buildout: 'eggs' 'scripts'\."),
"Unused options for buildout: 'scripts' 'eggs'."),
(re.compile('distribute'), 'setuptools'),
......
......@@ -65,7 +65,7 @@ Now if we run the buildout, the buildout will upgrade itself to the
new versions found in new releases:
>>> print system(buildout),
Getting distribution for 'zc.buildout'.
Getting distribution for 'zc.buildout>=1.99'.
Got zc.buildout 99.99.
Getting distribution for 'setuptools'.
Got setuptools 99.99.
......@@ -200,7 +200,7 @@ directory:
Creating directory '/sample_buildout2/parts'.
Creating directory '/sample_buildout2/eggs'.
Creating directory '/sample_buildout2/develop-eggs'.
Getting distribution for 'zc.buildout'.
Getting distribution for 'zc.buildout>=1.99'.
Got zc.buildout 99.99.
Getting distribution for 'setuptools'.
Got setuptools 99.99.
......@@ -233,7 +233,7 @@ We'll mimic this by passing the argument actually in the command line.
>>> print system(buildout +
... ' buildout:accept-buildout-test-releases=true'),
... # doctest: +NORMALIZE_WHITESPACE
Getting distribution for 'zc.buildout'.
Getting distribution for 'zc.buildout>=1.99'.
Got zc.buildout 100.0b1.
Upgraded:
zc.buildout version 100.0b1,
......
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