Commit 03e8aa86 authored by Reinout van Rees's avatar Reinout van Rees

Checking python version when specified.

The [versions] section is checked for a 'python' key.
Functionality copied from buildout-versions.
Includes documentation and tests.
parent 4eb822a3
...@@ -204,8 +204,6 @@ class Buildout(DictMixin): ...@@ -204,8 +204,6 @@ class Buildout(DictMixin):
# apply command-line options # apply command-line options
_update(data, cloptions) _update(data, cloptions)
# REINOUT: potentially add a lowercase-key-using special kind of dict
# for the versions.
# Set up versions section, if necessary # Set up versions section, if necessary
if 'versions' not in data['buildout']: if 'versions' not in data['buildout']:
data['buildout']['versions'] = ('versions', 'DEFAULT_VALUE') data['buildout']['versions'] = ('versions', 'DEFAULT_VALUE')
...@@ -232,13 +230,12 @@ class Buildout(DictMixin): ...@@ -232,13 +230,12 @@ class Buildout(DictMixin):
if k not in versions if k not in versions
)) ))
# REINOUT: add check for python version. python_version = versions.get('python')
# python_version = current_versions.get('python') if python_version and python_version[0] not in sys.version:
# if python_version and python_version not in sys.version: raise zc.buildout.easy_install.IncompatibleConstraintError(
# raise IncompatibleVersionError( "python version specified not found in sys.version:",
# "python version specified not found in sys.version:", python_version
# python_version )
# )
# REINOUT: look for buildout versions file option. # REINOUT: look for buildout versions file option.
# # record file name, if needed # # record file name, if needed
...@@ -322,7 +319,7 @@ class Buildout(DictMixin): ...@@ -322,7 +319,7 @@ class Buildout(DictMixin):
# finish w versions # finish w versions
if versions_section_name: if versions_section_name:
# refetching section name just to avoid a warnin # refetching section name just to avoid a warning
versions = self[versions_section_name] versions = self[versions_section_name]
else: else:
# remove annotations # remove annotations
......
...@@ -227,3 +227,50 @@ We can also disable checking versions: ...@@ -227,3 +227,50 @@ We can also disable checking versions:
Uninstalling foo. Uninstalling foo.
Installing foo. Installing foo.
recipe v2 recipe v2
Controlling the python version
-------------------------------
Sometimes you know that your buildout should always use a specific python
version. You can add use ``python`` in your version list and buildout will
give an error if the version doesn't match:
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = foo
...
... [versions]
... python = 1.5
... spam = 1
...
... [foo]
... recipe = spam
... ''')
If we run the buildout, it will complain:
>>> print_(system(buildout), end='')
While:
Initializing.
Error: python version specified not found in sys.version: ('1.5', '/sample-buildout/buildout.cfg')
Now the same with a correct version:
>>> import sys
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = foo
...
... [versions]
... python = %s.%s
... spam = 1
...
... [foo]
... recipe = spam
... ''' % (sys.version_info.major, sys.version_info.minor))
>>> print_(system(buildout), end='')
Uninstalling foo.
Installing foo.
recipe v1
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