Commit 93f94401 authored by Reinout van Rees's avatar Reinout van Rees

Got printing of picked versions to file working.

An 'update-versions-file' option points at a file you want updated.
parent 19165bc0
...@@ -29,6 +29,7 @@ except ImportError: ...@@ -29,6 +29,7 @@ except ImportError:
import zc.buildout.configparser import zc.buildout.configparser
import copy import copy
import datetime
import distutils.errors import distutils.errors
import glob import glob
import itertools import itertools
...@@ -138,6 +139,7 @@ _buildout_default_options = _annotate_section({ ...@@ -138,6 +139,7 @@ _buildout_default_options = _annotate_section({
'python': 'buildout', 'python': 'buildout',
'show-picked-versions': 'false', 'show-picked-versions': 'false',
'socket-timeout': '', 'socket-timeout': '',
'update-versions-file': '',
'use-dependency-links': 'true', 'use-dependency-links': 'true',
}, 'DEFAULT_VALUE') }, 'DEFAULT_VALUE')
...@@ -336,6 +338,7 @@ class Buildout(DictMixin): ...@@ -336,6 +338,7 @@ class Buildout(DictMixin):
bool_option(options, 'allow-picked-versions')) bool_option(options, 'allow-picked-versions'))
self.show_picked_versions = bool_option(options, self.show_picked_versions = bool_option(options,
'show-picked-versions') 'show-picked-versions')
self.update_versions_file = options['update-versions-file']
zc.buildout.easy_install.show_picked_versions( zc.buildout.easy_install.show_picked_versions(
self.show_picked_versions) self.show_picked_versions)
...@@ -1022,18 +1025,19 @@ class Buildout(DictMixin): ...@@ -1022,18 +1025,19 @@ class Buildout(DictMixin):
print_("Versions had to be automatically picked.") print_("Versions had to be automatically picked.")
print_("The following part definition lists the versions picked:") print_("The following part definition lists the versions picked:")
print_('\n'.join(output)) print_('\n'.join(output))
# REINOUT Print to file if self.update_versions_file:
# if file_name: # Also write to the versions file.
# if os.path.exists(file_name): if os.path.exists(self.update_versions_file):
# output[:1] = [ output[:1] = [
# '', '',
# '# Added by Buildout Versions at %s' % datetime.now(), '# Added by buildout at %s' % datetime.datetime.now(),
# ] ]
# output.append('') output.append('')
# f = open(file_name,'a') f = open(self.update_versions_file, 'a')
# f.write('\n'.join(output)) f.write('\n'.join(output))
# f.close() f.close()
# print("This information has been written to %r" % file_name) print_("This information has been written to " +
self.update_versions_file)
def setup(self, args): def setup(self, args):
if not args: if not args:
......
...@@ -304,6 +304,72 @@ and case differences won't impact the pinning: ...@@ -304,6 +304,72 @@ and case differences won't impact the pinning:
Updating foo. Updating foo.
recipe v2 recipe v2
Sometimes it is handy to have a separate file with versions. This is a regular
buildout file with a single ``[versions]`` section. You include it by
extending from that versions file:
>>> write('my_versions.cfg',
... '''
... [versions]
... distribute = 0.6.34
... spam = 2
... ''')
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = foo
... extends = my_versions.cfg
... find-links = %s
... show-picked-versions = true
...
... [foo]
... recipe = spam
... ''' % join('recipe', 'dist'))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo.
recipe v2
If not everything is pinned and buildout has to pick versions, you can tell
buildout to append the versions to your versions file. It simply appends them
at the end.
>>> write('my_versions.cfg',
... '''
... [versions]
... distribute = 0.6.34
... ''')
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = foo
... extends = my_versions.cfg
... update-versions-file = my_versions.cfg
... find-links = %s
... show-picked-versions = true
...
... [foo]
... recipe = spam
... ''' % join('recipe', 'dist'))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo.
recipe v2
Versions had to be automatically picked.
The following part definition lists the versions picked:
[versions]
spam = 2
This information has been written to my_versions.cfg
The versions file now contains the extra pin:
>>> 'spam = 2' in open('my_versions.cfg').read()
True
And re-running buildout doesn't report any picked versions anymore:
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo.
recipe v2
Controlling the python version Controlling the python version
------------------------------- -------------------------------
......
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