Join GitHub today
Transitive dependencies in setup_requires should be able to override system versions #1124
This is basically the same issue as #223 but for transitive dependencies.
When a package
The proper version of
Minimal steps to reproduce the issue:
(in a virtualenv, python 2.7.13)
EDIT: clarified the problem definition.
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` )
> rm -rf venv .eggs && python -m venv venv && ./venv/bin/pip install -U setuptools && ./venv/bin/python setup.py clean
rm -rf venv .eggs && python -m venv venv && ./venv/bin/pip install -U setuptools 'python-xlib==0.17' && ./venv/bin/python setup.py clean
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]:
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.