Commit d3c78d5c authored by Jim Fulton's avatar Jim Fulton

Make sure (???) buildout doesn't downgrade due to defer-final

parent d0672d2c
......@@ -287,6 +287,7 @@ class Buildout(DictMixin):
self.newest = (newest == 'true')
versions = {}
self.versions = versions
versions_section = options.get('versions')
if versions_section:
versions.update(dict(self[versions_section]))
......@@ -854,6 +855,16 @@ class Buildout(DictMixin):
if not self.newest:
return
# 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 + ' ' + self['buildout'].get(spec+'-version', '')).strip()
......
......@@ -2261,7 +2261,7 @@ database is shown.
... """)
>>> print_(system(buildout+' -vv'), end='') # doctest: +NORMALIZE_WHITESPACE
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.9a1', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -2289,6 +2289,7 @@ database is shown.
socket-timeout =
use-dependency-links = true
verbosity = 20
zc.buildout-version = >=1.9a1
<BLANKLINE>
All of these options can be overridden by configuration files or by
......
......@@ -128,7 +128,7 @@ about versions used. If we run the buildout in verbose mode without
specifying a versions section:
>>> print_(system(buildout+' buildout:versions= -v'), end='')
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -150,7 +150,7 @@ that we can fix them in a versions section.
If we run the buildout with the versions section:
>>> print_(system(buildout+' -v'), end='')
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......
......@@ -330,7 +330,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'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -527,7 +527,7 @@ def create_sections_on_command_line():
>>> print_(system(buildout + ' foo:bar=1 -vv'), end='')
... # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
...
[foo]
bar = 1
......@@ -1946,7 +1946,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'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -2227,7 +2227,7 @@ The default is prefer-final = true:
... ''' % globals())
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
...
Picked: demo = 0.3
...
......@@ -2249,7 +2249,7 @@ We get the same behavior if we add prefer-final = true
... ''' % globals())
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
...
Picked: demo = 0.3
...
......@@ -2271,7 +2271,7 @@ distributions:
... ''' % globals())
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout >=1.99', 'distribute'.
...
Picked: demo = 0.4c1
...
......@@ -2295,6 +2295,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 =')]
[u'>.1']
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... versions = versions
... [versions]
... zc.buildout = 43
... ''')
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing...
Error: Couldn't find a distribution for 'zc.buildout==43'.
"""
......@@ -2913,6 +2957,8 @@ def test_suite():
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_egg_py,
zc.buildout.testing.not_found,
(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),
......@@ -2947,6 +2993,9 @@ def test_suite():
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_egg_py,
zc.buildout.testing.not_found,
(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('[-d] distribute-\S+[.]egg'), 'distribute.egg'),
......@@ -3000,6 +3049,9 @@ def test_suite():
zc.buildout.testing.not_found,
normalize_bang,
normalize_S,
(re.compile(r"Installing 'zc.buildout >=\S+"), ''),
(re.compile(r"Getting distribution for 'zc.buildout>=\S+"),
''),
(re.compile('99[.]99'), 'NINETYNINE.NINETYNINE'),
(re.compile(
r'(zc.buildout|distribute)( version)? \d+[.]\d+\S*'),
......@@ -3062,6 +3114,7 @@ def test_suite():
zc.buildout.testing.normalize_egg_py,
zc.buildout.testing.normalize___pycache__,
zc.buildout.testing.not_found,
(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'),
......
......@@ -66,7 +66,7 @@ Now if we run the buildout, the buildout will upgrade itself to the
new versions found in new releases:
>>> print_(system(buildout), end='')
Getting distribution for 'zc.buildout'.
Getting distribution for 'zc.buildout>=1.99'.
Got zc.buildout 99.99.
Getting distribution for 'distribute'.
Got distribute 99.99.
......@@ -177,7 +177,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 'distribute'.
Got distribute 99.99.
......
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