Commit 7ebea29b authored by Reinout van Rees's avatar Reinout van Rees

Fixed #71: when needed, write versions to file

Picked versions are stored for later printing/writing in the Installer
also when show-picked-versions is set to false but update-versions-file is set
to a file. Previously, show-picked-versions=false would also disable the versions
file updating.
parent 9f175c99
...@@ -325,8 +325,8 @@ class Buildout(DictMixin): ...@@ -325,8 +325,8 @@ class Buildout(DictMixin):
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'] self.update_versions_file = options['update-versions-file']
zc.buildout.easy_install.show_picked_versions( zc.buildout.easy_install.store_picked_versions(
self.show_picked_versions) self.show_picked_versions or self.update_versions_file)
download_cache = options.get('download-cache') download_cache = options.get('download-cache')
if download_cache: if download_cache:
...@@ -996,8 +996,6 @@ class Buildout(DictMixin): ...@@ -996,8 +996,6 @@ class Buildout(DictMixin):
def _print_picked_versions(self): def _print_picked_versions(self):
Installer = zc.buildout.easy_install.Installer Installer = zc.buildout.easy_install.Installer
if not self.show_picked_versions:
return
if not Installer._picked_versions: if not Installer._picked_versions:
# Don't print empty output. # Don't print empty output.
return return
...@@ -1016,11 +1014,13 @@ class Buildout(DictMixin): ...@@ -1016,11 +1014,13 @@ class Buildout(DictMixin):
output.extend(required_output) output.extend(required_output)
if self.show_picked_versions:
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))
if self.update_versions_file: if self.update_versions_file:
# Also write to the versions file. # Write to the versions file.
if os.path.exists(self.update_versions_file): if os.path.exists(self.update_versions_file):
output[:1] = [ output[:1] = [
'', '',
......
...@@ -129,7 +129,7 @@ class Installer: ...@@ -129,7 +129,7 @@ class Installer:
_prefer_final = True _prefer_final = True
_use_dependency_links = True _use_dependency_links = True
_allow_picked_versions = True _allow_picked_versions = True
_show_picked_versions = False _store_picked_versions = False
def __init__(self, def __init__(self,
dest=None, dest=None,
...@@ -734,10 +734,10 @@ def allow_picked_versions(setting=None): ...@@ -734,10 +734,10 @@ def allow_picked_versions(setting=None):
Installer._allow_picked_versions = bool(setting) Installer._allow_picked_versions = bool(setting)
return old return old
def show_picked_versions(setting=None): def store_picked_versions(setting=None):
old = Installer._show_picked_versions old = Installer._store_picked_versions
if setting is not None: if setting is not None:
Installer._show_picked_versions = bool(setting) Installer._store_picked_versions = bool(setting)
return old return old
...@@ -1260,7 +1260,7 @@ class MissingDistribution(zc.buildout.UserError): ...@@ -1260,7 +1260,7 @@ class MissingDistribution(zc.buildout.UserError):
def _log_requirement(ws, req): def _log_requirement(ws, req):
if (not logger.isEnabledFor(logging.DEBUG) and if (not logger.isEnabledFor(logging.DEBUG) and
not Installer._show_picked_versions): not Installer._store_picked_versions):
# Sorting the working set and iterating over it's requirements # Sorting the working set and iterating over it's requirements
# is expensive, so short circuit the work if it won't even be # is expensive, so short circuit the work if it won't even be
# logged. When profiling a simple buildout with 10 parts with # logged. When profiling a simple buildout with 10 parts with
......
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