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):
# apply command-line options
_update(data, cloptions)
# REINOUT: potentially add a lowercase-key-using special kind of dict
# for the versions.
# Set up versions section, if necessary
if 'versions' not in data['buildout']:
data['buildout']['versions'] = ('versions', 'DEFAULT_VALUE')
......@@ -232,13 +230,12 @@ class Buildout(DictMixin):
if k not in versions
))
# REINOUT: add check for python version.
# python_version = current_versions.get('python')
# if python_version and python_version not in sys.version:
# raise IncompatibleVersionError(
# "python version specified not found in sys.version:",
# python_version
# )
python_version = versions.get('python')
if python_version and python_version[0] not in sys.version:
raise zc.buildout.easy_install.IncompatibleConstraintError(
"python version specified not found in sys.version:",
python_version
)
# REINOUT: look for buildout versions file option.
# # record file name, if needed
......@@ -322,7 +319,7 @@ class Buildout(DictMixin):
# finish w versions
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]
else:
# remove annotations
......
......@@ -227,3 +227,50 @@ We can also disable checking versions:
Uninstalling foo.
Installing foo.
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