Commit 3ce003a0 authored by Jim Fulton's avatar Jim Fulton

Get rid of the zc.buildout-version and distribute-versions options in

favor of the versions sections.

Add default versions to the versions section, if possible.
This means adding a versions section (if necessary/possible).
parent a91cd3f4
......@@ -4,13 +4,23 @@ Change History
2.0.0a8 (2013-01-??)
====================
- The ``versions`` option now defaults to ``versions`` (if there is a
``versions`` section), so you know longer need to include::
- The ``versions`` option now defaults to ``versions``, so you know
longer need to include::
versions = versions
in a ``buildout`` section when pinning versions.
A ``versions`` section is added, if necessary, if a ``versions``
option isn't used.
- Buildout-defined default versions are included in the versions
section, if there is one.
- The ``buildout:zc.buildout-version`` and
``buildout:distribute-version`` options have been removed in favor
of providing version constraints in a versions section.
Fixed: relative-paths weren't honored when bootstrapping or upgrading
(which is how the buildout script gets generated).
......
......@@ -204,10 +204,37 @@ class Buildout(DictMixin):
# apply command-line options
_update(data, cloptions)
# Set up versions section, if necessary
if 'versions' not in data['buildout']:
data['buildout']['versions'] = 'versions', 'DEFAULT_VALUE'
if 'versions' not in data:
data['versions'] = {}
# Default versions:
versions_section_name = data['buildout']['versions'][0]
if versions_section_name:
versions = data[versions_section_name]
else:
versions = {}
versions.update(
dict((k, (v, 'DEFAULT_VALUE'))
for (k, v) in (
# Prevent downgrading due to prefer-final:
('zc.buildout',
'>='+pkg_resources.working_set.find(
pkg_resources.Requirement.parse('zc.buildout')
).version),
# Use 2, even though not final
('zc.recipe.egg', '>=2.0.0a3'),
)
if k not in versions
))
self._annotated = copy.deepcopy(data)
self._raw = _unannotate(data)
self._data = {}
self._parts = []
# provide some defaults before options are parsed
# because while parsing options those attributes might be
# used already (Gottfried Ganssauge)
......@@ -275,13 +302,15 @@ class Buildout(DictMixin):
self._setup_logging()
self._setup_socket_timeout()
versions = {'zc.recipe.egg': '>=2.0.0a3'}
# finish w versions
if versions_section_name:
# refetching section name just to avoid a warnin
versions = self[versions_section_name]
else:
# remove annotations
versions = dict((k, v[0]) for (k, v) in versions.items())
options['versions'] # refetching section name just to avoid a warning
self.versions = versions
if 'versions' not in options and 'versions' in self:
options['versions'] = 'versions'
versions_section = options.get('versions')
if versions_section:
versions.update(dict(self[versions_section]))
zc.buildout.easy_install.default_versions(versions)
zc.buildout.easy_install.prefer_final(
......@@ -835,21 +864,8 @@ 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()
for spec in ('zc.buildout', 'distribute')
],
('zc.buildout', 'distribute'),
self['buildout']['eggs-directory'],
links = self['buildout'].get('find-links', '').split(),
index = self['buildout'].get('index'),
......@@ -902,6 +918,7 @@ class Buildout(DictMixin):
# the new dist is different, so we've upgraded.
# Update the scripts and return True
options = self['buildout']
zc.buildout.easy_install.scripts(
['zc.buildout'], ws, sys.executable,
self['buildout']['bin-directory'],
......@@ -1274,6 +1291,9 @@ class Options(DictMixin):
self.name)
return self._created
def __repr__(self):
return repr(dict(self))
_spacey_nl = re.compile('[ \t\r\f\v]*\n[ \t\r\f\v\n]*'
'|'
'^[ \t\r\f\v]+'
......
......@@ -837,6 +837,8 @@ COMMAND_LINE_VALUE).
DEFAULT_VALUE
use-dependency-links= true
DEFAULT_VALUE
versions= versions
DEFAULT_VALUE
<BLANKLINE>
[data-dir]
path= foo bins
......@@ -844,6 +846,12 @@ COMMAND_LINE_VALUE).
recipe= recipes:mkdir
/sample-buildout/buildout.cfg
<BLANKLINE>
[versions]
zc.buildout= >=1.99
DEFAULT_VALUE
zc.recipe.egg= >=1.99
DEFAULT_VALUE
<BLANKLINE>
Variable substitutions
----------------------
......@@ -1279,6 +1287,12 @@ operations.
[part4]
option= h1 h2
/sample-buildout/extension1.cfg
[versions]
zc.buildout= >=1.99
DEFAULT_VALUE
zc.recipe.egg= >=1.99
DEFAULT_VALUE
<BLANKLINE>
Cleanup.
......@@ -2326,7 +2340,7 @@ database is shown.
... """)
>>> print_(system(buildout+' -vv'), end='') # doctest: +NORMALIZE_WHITESPACE
Installing 'zc.buildout >=1.9a1', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -2354,7 +2368,10 @@ database is shown.
socket-timeout =
use-dependency-links = true
verbosity = 20
zc.buildout-version = >=1.9a1
versions = versions
[versions]
zc.buildout = >=1.99
zc.recipe.egg = >=1.99
<BLANKLINE>
All of these options can be overridden by configuration files or by
......@@ -2835,9 +2852,9 @@ previous section:
... """
... import sys
... def ext(buildout):
... sys.stdout.write('%s %s\\n' % ('ext', list(buildout)))
... sys.stdout.write('%s %s\\n' % ('ext', sorted(buildout)))
... def unload(buildout):
... sys.stdout.write('%s %s\\n' % ('unload', list(buildout)))
... sys.stdout.write('%s %s\\n' % ('unload', sorted(buildout)))
... """)
>>> write(sample_bootstrapped, 'demo', 'setup.py',
......@@ -2890,6 +2907,6 @@ We see that our extension is loaded and executed:
>>> print_(system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
... end='')
ext ['buildout']
ext ['buildout', 'versions']
Develop: '/sample-bootstrapped/demo'
unload ['buildout']
unload ['buildout', 'versions']
......@@ -127,7 +127,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 >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -149,7 +149,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 >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......
......@@ -333,7 +333,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 >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -530,7 +530,7 @@ def create_sections_on_command_line():
>>> print_(system(buildout + ' foo:bar=1 -vv'), end='')
... # doctest: +ELLIPSIS
Installing 'zc.buildout >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
[foo]
bar = 1
......@@ -958,7 +958,7 @@ def extensions_installed_as_eggs_work_in_offline_mode():
... def print_(*args):
... sys.stdout.write(' '.join(map(str, args)) + '\\n')
... def ext(buildout):
... print_('ext', list(buildout))
... print_('ext', sorted(buildout))
... """)
>>> write('demo', 'setup.py',
......@@ -984,7 +984,7 @@ def extensions_installed_as_eggs_work_in_offline_mode():
... """)
>>> print_(system(join(sample_buildout, 'bin', 'buildout')), end='')
ext ['buildout']
ext ['buildout', 'versions']
'''
......@@ -1949,7 +1949,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 >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'distribute'.
Picked: distribute = 0.6
......@@ -2230,7 +2230,7 @@ The default is prefer-final = true:
... ''' % globals())
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
Picked: demo = 0.3
...
......@@ -2252,7 +2252,7 @@ We get the same behavior if we add prefer-final = true
... ''' % globals())
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
Picked: demo = 0.3
...
......@@ -2274,7 +2274,7 @@ distributions:
... ''' % globals())
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing 'zc.buildout >=1.99', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
Picked: demo = 0.4c1
...
......@@ -2304,18 +2304,19 @@ 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.
isn't specified using a versions entry, then buildout's version
requirement gets set to >=CURRENT_VERSION.
>>> write('buildout.cfg',
... '''
... [buildout]
... parts =
... ''')
>>> [v] = [l.split('=', 1)[1].strip()
>>> [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(
... if l.startswith('zc.buildout = >=')]
>>> v == pkg_resources.working_set.find(
... pkg_resources.Requirement.parse('zc.buildout')
... ).version
True
......@@ -2324,12 +2325,13 @@ def wont_downgrade_due_to_prefer_final():
... '''
... [buildout]
... parts =
... zc.buildout-version = >.1
... [versions]
... zc.buildout = >.1
... ''')
>>> [str(l.split('=', 1)[1].strip())
>>> [str(l.split('= >', 1)[1].strip())
... for l in system(buildout+' -vv').split('\n')
... if l.startswith('zc.buildout-version =')]
['>.1']
... if l.startswith('zc.buildout =')]
['.1']
>>> write('buildout.cfg',
... '''
......@@ -2339,9 +2341,9 @@ def wont_downgrade_due_to_prefer_final():
... [versions]
... zc.buildout = 43
... ''')
>>> print_(system(buildout+' -v'), end='') # doctest: +ELLIPSIS
Installing...
Error: Couldn't find a distribution for 'zc.buildout==43'.
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Getting distribution for 'zc.buildout==43'.
...
"""
......@@ -3097,8 +3099,7 @@ 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(r"Installing 'zc.buildout >=\S+"), ''),
(re.compile('__buildout_signature__ = recipes-\S+'),
'__buildout_signature__ = recipes-SSSSSSSSSSS'),
(re.compile('executable = [\S ]+python\S*', re.I),
......@@ -3121,6 +3122,8 @@ def test_suite():
),
(re.compile('distribute'), 'setuptools'),
(re.compile('Got zc.recipe.egg \S+'), 'Got zc.recipe.egg'),
(re.compile(r'zc\.(buildout|recipe\.egg)\s*= >=\S+'),
'zc.\1 = >=1.99'),
])
) + manuel.capture.Manuel(),
'buildout.txt',
......@@ -3137,9 +3140,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(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'),
......@@ -3193,7 +3196,7 @@ def test_suite():
zc.buildout.testing.not_found,
normalize_bang,
normalize_S,
(re.compile(r"Installing 'zc.buildout >=\S+"), ''),
# (re.compile(r"Installing 'zc.buildout >=\S+"), ''),
(re.compile(r"Getting distribution for 'zc.buildout>=\S+"),
''),
(re.compile('99[.]99'), 'NINETYNINE.NINETYNINE'),
......@@ -3259,7 +3262,6 @@ def test_suite():
zc.buildout.testing.normalize___pycache__,
zc.buildout.testing.not_found,
normalize_bang,
(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'),
......
......@@ -107,8 +107,10 @@ will install earlier versions of these packages:
... index = %(new_releases)s
... parts = show-versions
... develop = showversions
... zc.buildout-version = < 99
... distribute-version = < 99
...
... [versions]
... zc.buildout = < 99
... distribute = < 99
...
... [show-versions]
... recipe = showversions
......
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