Commit 19165bc0 authored by Reinout van Rees's avatar Reinout van Rees

Moved picked version printer so we can use print_()

parent 837a4acf
......@@ -334,8 +334,10 @@ class Buildout(DictMixin):
bool_option(options, 'use-dependency-links'))
zc.buildout.easy_install.allow_picked_versions(
bool_option(options, 'allow-picked-versions'))
self.show_picked_versions = bool_option(options,
'show-picked-versions')
zc.buildout.easy_install.show_picked_versions(
bool_option(options, 'show-picked-versions'))
self.show_picked_versions)
download_cache = options.get('download-cache')
if download_cache:
......@@ -648,7 +650,7 @@ class Buildout(DictMixin):
elif (not installed_parts) and installed_exists:
os.remove(self['buildout']['installed'])
zc.buildout.easy_install.print_picked_versions()
self._print_picked_versions()
self._unload_extensions()
def _update_installed(self, **buildout_options):
......@@ -995,6 +997,44 @@ class Buildout(DictMixin):
'zc.buildout.unloadextension'):
ep.load()(self)
def _print_picked_versions(self):
Installer = zc.buildout.easy_install.Installer
if not self.show_picked_versions:
return
if not Installer._picked_versions:
# Don't print empty output.
return
output = ['[versions]']
required_output = []
for dist_, version in sorted(Installer._picked_versions.items()):
if dist_ in Installer._required_by:
required_output.append('')
required_output.append('# Required by:')
for req_ in sorted(Installer._required_by[dist_]):
required_output.append('# '+req_)
target = required_output
else:
target = output
target.append("%s = %s" % (dist_, version))
output.extend(required_output)
print_("Versions had to be automatically picked.")
print_("The following part definition lists the versions picked:")
print_('\n'.join(output))
# REINOUT Print to file
# if file_name:
# if os.path.exists(file_name):
# output[:1] = [
# '',
# '# Added by Buildout Versions at %s' % datetime.now(),
# ]
# output.append('')
# f = open(file_name,'a')
# f.write('\n'.join(output))
# f.close()
# print("This information has been written to %r" % file_name)
def setup(self, args):
if not args:
raise zc.buildout.UserError(
......
......@@ -739,42 +739,6 @@ def show_picked_versions(setting=None):
Installer._show_picked_versions = bool(setting)
return old
def print_picked_versions():
if not Installer._show_picked_versions:
return
if not Installer._picked_versions:
# Don't print empty output.
return
output = ['[versions]']
required_output = []
for dist_, version in sorted(Installer._picked_versions.items()):
if dist_ in Installer._required_by:
required_output.append('')
required_output.append('# Required by:')
for req_ in sorted(Installer._required_by[dist_]):
required_output.append('# '+req_)
target = required_output
else:
target = output
target.append("%s = %s" % (dist_, version))
output.extend(required_output)
print("Versions had to be automatically picked.")
print("The following part definition lists the versions picked:")
print('\n'.join(output))
# if file_name:
# if os.path.exists(file_name):
# output[:1] = [
# '',
# '# Added by Buildout Versions at %s' % datetime.now(),
# ]
# output.append('')
# f = open(file_name,'a')
# f.write('\n'.join(output))
# f.close()
# print("This information has been written to %r" % file_name)
def install(specs, dest,
links=(), index=None,
......
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