diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-04-15 09:03:49 +0200 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-04-15 09:03:49 +0200 |
commit | dd5caefb987dbd15495047fc653fa71d4667eb43 (patch) | |
tree | e79461dbd70903addafc07aafe84a44eb397ba82 | |
parent | bc35160987a7dda23de0c898a7e8ae4363504cde (diff) | |
download | external_python_setuptools-dd5caefb987dbd15495047fc653fa71d4667eb43.tar.gz external_python_setuptools-dd5caefb987dbd15495047fc653fa71d4667eb43.tar.bz2 external_python_setuptools-dd5caefb987dbd15495047fc653fa71d4667eb43.zip |
Always inject extra into the environment when evaluating markers. Fixes #544.
-rw-r--r-- | CHANGES.rst | 6 | ||||
-rw-r--r-- | pkg_resources/__init__.py | 4 | ||||
-rw-r--r-- | pkg_resources/tests/test_resources.py | 10 |
3 files changed, 9 insertions, 11 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 40cab4fb..acfe3df3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,12 @@ CHANGES ======= +v20.8.1 +------- + +* Issue #544: Fix issue with extra environment marker + processing in WorkingSet due to refactor in v20.7.0. + v20.8.0 ------- diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index ce4e7755..2eab8230 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -988,9 +988,9 @@ class _ReqExtras(dict): """ extra_evals = ( req.marker.evaluate({'extra': extra}) - for extra in self.get(req, ()) + for extra in self.get(req, ()) + (None,) ) - return not req.marker or any(extra_evals) or req.marker.evaluate() + return not req.marker or any(extra_evals) class Environment(object): diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 0a72d941..31847dc8 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -189,7 +189,7 @@ class TestDistro: def test_environment_marker_evaluation_called(self): """ If one package foo requires bar without any extras, - markers should pass for bar. + markers should pass for bar without extras. """ parent_req, = parse_requirements("foo") req, = parse_requirements("bar;python_version>='2'") @@ -201,14 +201,6 @@ class TestDistro: req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) assert req_extras.markers_pass(req) - # extra should not be present in the marker namespace if - # no markers were supplied - parent_req, = parse_requirements("foo") - req, = parse_requirements("bar;extra==''") - req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) - with pytest.raises(packaging.markers.UndefinedEnvironmentName): - req_extras.markers_pass(req) - def test_marker_evaluation_with_extras(self): """Extras are also evaluated as markers at resolution time.""" ad = pkg_resources.Environment([]) |