Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
23d5e4a8
Commit
23d5e4a8
authored
Jan 04, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test the report method
parent
880ccea0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
+33
-11
pkg_resources/__init__.py
pkg_resources/__init__.py
+29
-4
pkg_resources/tests/test_resources.py
pkg_resources/tests/test_resources.py
+3
-3
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+1
-4
No files found.
pkg_resources/__init__.py
View file @
23d5e4a8
...
...
@@ -317,8 +317,34 @@ class ResolutionError(Exception):
def __repr__(self):
return self.__class__.__name__+repr(self.args)
class VersionConflict(ResolutionError):
"""
An
already
-
installed
version
conflicts
with
the
requested
version
"""
"""
An
already
-
installed
version
conflicts
with
the
requested
version
.
Should
be
initialized
with
the
installed
Distribution
,
the
requested
Requirement
,
and
optionally
a
list
of
dists
that
required
the
installed
Distribution
.
"""
@property
def dist(self):
return self.args[0]
@property
def req(self):
return self.args[1]
@property
def required_by(self):
return self.args[2] if len(self.args) > 2 else []
def report(self):
template = "{self.dist} is installed but {self.req} is required"
if self.required_by:
template += " by {self.required_by}"
return template.format(**locals())
class DistributionNotFound(ResolutionError):
"""
A
requested
distribution
was
not
found
"""
...
...
@@ -763,9 +789,8 @@ class WorkingSet(object):
to_activate.append(dist)
if dist not in req:
# Oops, the "best" so far conflicts with a dependency
tmpl = "%s is installed but %s is required by %s"
args = dist, req, list(required_by.get(req, []))
raise VersionConflict(tmpl % args)
dependent_req = list(required_by.get(req, []))
raise VersionConflict(dist, req, dependent_req)
# push the new requirements onto the stack
new_requirements = dist.requires(req.extras)[::-1]
...
...
pkg_resources/tests/test_resources.py
View file @
23d5e4a8
...
...
@@ -175,8 +175,8 @@ class TestDistro:
with
pytest
.
raises
(
VersionConflict
)
as
vc
:
ws
.
resolve
(
parse_requirements
(
"Foo==1.2
\
n
Foo!=1.2"
),
ad
)
msg
=
'Foo 0.9 is installed but Foo==1.2 is required
by []
'
assert
str
(
vc
).
endswith
(
msg
)
msg
=
'Foo 0.9 is installed but Foo==1.2 is required'
assert
vc
.
value
.
report
()
==
msg
def
testDistroDependsOptions
(
self
):
d
=
self
.
distRequires
(
"""
...
...
@@ -218,7 +218,7 @@ class TestWorkingSet:
ws
.
find
(
req
)
msg
=
'Foo 1.2 is installed but Foo<1.2 is required'
assert
str
(
vc
).
endswith
(
msg
)
assert
vc
.
value
.
report
()
==
msg
class
TestEntryPoints
:
...
...
setuptools/command/easy_install.py
View file @
23d5e4a8
...
...
@@ -703,10 +703,7 @@ Please make the appropriate changes for your system and try again.
"Could not find required distribution %s"
%
e
.
args
)
except
VersionConflict
as
e
:
raise
DistutilsError
(
"Installed distribution %s conflicts with requirement %s"
%
e
.
args
)
raise
DistutilsError
(
e
.
report
())
if
self
.
always_copy
or
self
.
always_copy_from
:
# Force all the relevant distros to be copied or activated
for
dist
in
distros
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment