Transitive dependencies in setup_requires should be able to override system versions #1124
Comments
from setuptools import setup
setup(
name='my-test',
dependency_links=['deps/my-dep-0.0.1.tar.gz'],
setup_requires=['my-dep'] # my-dep has `python-xlib>=0.18` in its `install_requires`
) This work: > rm -rf venv .eggs && python -m venv venv && ./venv/bin/pip install -U setuptools && ./venv/bin/python setup.py clean This doesn't: rm -rf venv .eggs && python -m venv venv && ./venv/bin/pip install -U setuptools 'python-xlib==0.17' && ./venv/bin/python setup.py clean Tentative patch: pkg_resources/__init__.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git i/pkg_resources/__init__.py w/pkg_resources/__init__.py
index f13a69b3..cb6f512c 100644
--- i/pkg_resources/__init__.py
+++ w/pkg_resources/__init__.py
@@ -852,7 +852,10 @@ class WorkingSet(object):
# distribution
env = Environment([])
ws = WorkingSet([])
- dist = best[req.key] = env.best_match(req, ws, installer)
+ dist = best[req.key] = env.best_match(
+ req, ws, installer,
+ replace_conflicting=replace_conflicting
+ )
if dist is None:
requirers = required_by.get(req, None)
raise DistributionNotFound(req, requirers)
@@ -1104,7 +1107,7 @@ class Environment(object):
dists.append(dist)
dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
- def best_match(self, req, working_set, installer=None):
+ def best_match(self, req, working_set, installer=None, replace_conflicting=False):
"""Find distribution best matching `req` and usable on `working_set`
This calls the ``find(req)`` method of the `working_set` to see if a
@@ -1117,7 +1120,12 @@ class Environment(object):
calling the environment's ``obtain(req, installer)`` method will be
returned.
"""
- dist = working_set.find(req)
+ try:
+ dist = working_set.find(req)
+ except VersionConflict:
+ if not replace_conflicting:
+ raise
+ dist = None
if dist is not None:
return dist
for dist in self[req.key]: |
This change looks reasonable, though I do loathe the boolean switch being passed from method call to method call. |
Can this code tell the difference between something that was installed outside of It seems to be that it is important to differentiate the following two cases when considering the
Case 1 is the case we're trying to solve. Case 2 is the case I'm afraid we might be breaking. |
benoit-pierre
added a commit
to benoit-pierre/setuptools
that referenced
this issue
Aug 7, 2017
Correctly replace conflicting distributions in sub-requirements if possible (instead of only for top-level requirements passed as arguments). Fix pypa#1124.
@sitaktif: check the torture tests in #1129, I believe both use cases are handled:
|
benoit-pierre
added a commit
to benoit-pierre/setuptools
that referenced
this issue
Aug 29, 2017
Correctly replace conflicting distributions in sub-requirements if possible (instead of only for top-level requirements passed as arguments). Fix pypa#1124.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is basically the same issue as #223 but for transitive dependencies.
Issue:
When a package
my_pkg
depends (withinstall_requires
) onmy_transitive_dep
with a version that conflict with the currently installed version ofmy_transitive_dep
, addingmy_pkg
as asetup_requires
to thesetup.py
of a project fails to initialise the Distribution object and raisespkg_resources.VersionConflict
.Expected behaviour:
The proper version of
my_transitive_dep
is installed in.eggs
and the currently installed version ofmy_transitive_dep
is ignored.Minimal steps to reproduce the issue:
(in a virtualenv, python 2.7.13)
EDIT: clarified the problem definition.
The text was updated successfully, but these errors were encountered: