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

Merge pull request #213 from reinout/reinout-versionconflict-args-fix

Our VersionConflict handling could result in an UnpackError when rendering
parents 813a4590 f618b8ff
...@@ -8,10 +8,16 @@ Unreleased ...@@ -8,10 +8,16 @@ Unreleased
``site-packages`` directory: don't remove it from ``sys.path``. See ``site-packages`` directory: don't remove it from ``sys.path``. See
https://github.com/buildout/buildout/issues/217 https://github.com/buildout/buildout/issues/217
- Remove assumption that ``pkg_resources`` is a module (untrue since - Remove assumption that ``pkg_resources`` is a module (untrue since
release of `setuptools 8.3``). See release of `setuptools 8.3``). See
https://github.com/buildout/buildout/issues/227 https://github.com/buildout/buildout/issues/227
- Fix for #212. For certain kinds of conflict errors you'd get an UnpackError
when rendering the error message. Instead of a nicely formatted version
conflict message.
[reinout]
2.3.1 (2014-12-16) 2.3.1 (2014-12-16)
================== ==================
......
...@@ -1350,17 +1350,16 @@ class VersionConflict(zc.buildout.UserError): ...@@ -1350,17 +1350,16 @@ class VersionConflict(zc.buildout.UserError):
self.err, self.ws = err, ws self.err, self.ws = err, ws
def __str__(self): def __str__(self):
existing_dist, req = self.err.args result = ["There is a version conflict."]
result = ["There is a version conflict.", if len(self.err.args) == 2:
"We already have: %s" % existing_dist, existing_dist, req = self.err.args
] result.append("We already have: %s" % existing_dist)
stated = False for dist in self.ws:
for dist in self.ws: if req in dist.requires():
if req in dist.requires(): result.append("but %s requires %r." % (dist, str(req)))
result.append("but %s requires %r." % (dist, str(req))) else:
stated = True # The error argument is already a nice error string.
if not stated: result.append(self.err.args[0])
result.append("We require %s" % req)
return '\n'.join(result) return '\n'.join(result)
......
...@@ -361,6 +361,30 @@ If we use the verbose switch, we can see where requirements are coming from: ...@@ -361,6 +361,30 @@ If we use the verbose switch, we can see where requirements are coming from:
but sampley 1 requires 'demoneeded==1.0'. but sampley 1 requires 'demoneeded==1.0'.
""" """
def version_conflict_rendering():
"""
We use the arguments passed by pkg_resources.VersionConflict to construct a
nice error message:
>>> error = pkg_resources.VersionConflict('pkg1 2.1', 'pkg1 1.0')
>>> ws = [] # Not relevant for this test
>>> print_(zc.buildout.easy_install.VersionConflict(
... error, ws)) # doctest: +ELLIPSIS
There is a version conflict...
But sometimes pkg_resources passes a nicely formatted string itself already.
Extracting the original arguments fails in that case, so we just show the string.
>>> error = pkg_resources.VersionConflict('pkg1 2.1 is simply wrong')
>>> ws = [] # Not relevant for this test
>>> print_(zc.buildout.easy_install.VersionConflict(
... error, ws)) # doctest: +ELLIPSIS
There is a version conflict.
pkg1 2.1 is simply wrong
"""
def show_who_requires_missing_distributions(): def show_who_requires_missing_distributions():
""" """
......
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