From 1cdd940877e158f2b748f67f09d1f1321a113998 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Mon, 4 Apr 2016 16:27:32 +1000 Subject: Restore evaluating environment markers in WorkingSet Correctly deal with parsed requirements that include extras as a marker inside WorkingSet that are populated from METADATA inside wheels, like we get from pip>=7. This partially reverts commit 04d10ff025e1cbef7ec93a2008c930e856045c8a. Closes: #523 --- pkg_resources/__init__.py | 14 +++++-- pkg_resources/tests/test_resources.py | 79 ++++++++++++++++++++++++++++++++--- 2 files changed, 85 insertions(+), 8 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index eb84f4ba..4f0a487e 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -791,6 +791,8 @@ class WorkingSet(object): # key -> dist best = {} to_activate = [] + # Map requirement to the extras that require it + extra_req_mapping = {} # Mapping of requirement to set of distributions that required it; # useful for reporting info about conflicts. @@ -804,9 +806,14 @@ class WorkingSet(object): continue # If the req has a marker, evaluate it -- skipping the req if # it evaluates to False. - # https://github.com/pypa/setuptools/issues/523 - _issue_523_bypass = True - if not _issue_523_bypass and req.marker and not req.marker.evaluate(): + if req.marker: + result = [] + if req in extra_req_mapping: + for extra in extra_req_mapping[req] or ['']: + result.append(req.marker.evaluate({'extra': extra})) + else: + result.append(req.marker.evaluate()) + if not any(result): continue dist = best.get(req.key) if dist is None: @@ -840,6 +847,7 @@ class WorkingSet(object): # Register the new requirements needed by req for new_requirement in new_requirements: required_by[new_requirement].add(req.project_name) + extra_req_mapping[new_requirement] = req.extras processed[req] = True diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 98b8dcd7..7f86c797 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -171,16 +171,85 @@ class TestDistro: msg = 'Foo 0.9 is installed but Foo==1.2 is required' assert vc.value.report() == msg - @pytest.mark.xfail(reason="Functionality disabled; see #523") - def test_environment_markers(self): - """ - Environment markers are evaluated at resolution time. - """ + def test_environment_marker_evaluation_negative(self): + """Environment markers are evaluated at resolution time.""" ad = pkg_resources.Environment([]) ws = WorkingSet([]) res = ws.resolve(parse_requirements("Foo;python_version<'2'"), ad) assert list(res) == [] + def test_environment_marker_evaluation_positive(self): + ad = pkg_resources.Environment([]) + ws = WorkingSet([]) + Foo = Distribution.from_filename("/foo_dir/Foo-1.2.dist-info") + ad.add(Foo) + res = ws.resolve(parse_requirements("Foo;python_version>='2'"), ad) + assert list(res) == [Foo] + + def test_marker_evaluation_with_extras(self): + """Extras are also evaluated as markers at resolution time.""" + ad = pkg_resources.Environment([]) + ws = WorkingSet([]) + # Metadata needs to be native strings due to cStringIO behaviour in + # 2.6, so use str(). + Foo = Distribution.from_filename( + "/foo_dir/Foo-1.2.dist-info", + metadata=Metadata(("METADATA", str("Provides-Extra: baz\n" + "Requires-Dist: quux; extra=='baz'"))) + ) + ad.add(Foo) + assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo] + quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info") + ad.add(quux) + res = list(ws.resolve(parse_requirements("Foo[baz]"), ad)) + assert res == [Foo,quux] + + def test_marker_evaluation_with_multiple_extras(self): + ad = pkg_resources.Environment([]) + ws = WorkingSet([]) + # Metadata needs to be native strings due to cStringIO behaviour in + # 2.6, so use str(). + Foo = Distribution.from_filename( + "/foo_dir/Foo-1.2.dist-info", + metadata=Metadata(("METADATA", str("Provides-Extra: baz\n" + "Requires-Dist: quux; extra=='baz'\n" + "Provides-Extra: bar\n" + "Requires-Dist: fred; extra=='bar'\n"))) + ) + ad.add(Foo) + quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info") + ad.add(quux) + fred = Distribution.from_filename("/foo_dir/fred-0.1.dist-info") + ad.add(fred) + res = list(ws.resolve(parse_requirements("Foo[baz,bar]"), ad)) + assert sorted(res) == [fred,quux,Foo] + + def test_marker_evaluation_with_extras_loop(self): + ad = pkg_resources.Environment([]) + ws = WorkingSet([]) + # Metadata needs to be native strings due to cStringIO behaviour in + # 2.6, so use str(). + a = Distribution.from_filename( + "/foo_dir/a-0.2.dist-info", + metadata=Metadata(("METADATA", str("Requires-Dist: c[a]"))) + ) + b = Distribution.from_filename( + "/foo_dir/b-0.3.dist-info", + metadata=Metadata(("METADATA", str("Requires-Dist: c[b]"))) + ) + c = Distribution.from_filename( + "/foo_dir/c-1.0.dist-info", + metadata=Metadata(("METADATA", str("Provides-Extra: a\n" + "Requires-Dist: b;extra=='a'\n" + "Provides-Extra: b\n" + "Requires-Dist: foo;extra=='b'"))) + ) + foo = Distribution.from_filename("/foo_dir/foo-0.1.dist-info") + for dist in (a, b, c, foo): + ad.add(dist) + res = list(ws.resolve(parse_requirements("a"), ad)) + assert res == [a, c, b, foo] + def testDistroDependsOptions(self): d = self.distRequires(""" Twisted>=1.5 -- cgit v1.2.1 From 5c36cd3890dad731a0e3d9764345377406770c31 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 5 Apr 2016 11:59:18 +0100 Subject: Extract method for testing marker evaluation --- pkg_resources/__init__.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 4f0a487e..c3e3e96c 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -804,17 +804,10 @@ class WorkingSet(object): if req in processed: # Ignore cyclic or redundant dependencies continue - # If the req has a marker, evaluate it -- skipping the req if - # it evaluates to False. - if req.marker: - result = [] - if req in extra_req_mapping: - for extra in extra_req_mapping[req] or ['']: - result.append(req.marker.evaluate({'extra': extra})) - else: - result.append(req.marker.evaluate()) - if not any(result): - continue + + if not self._markers_pass(req, extra_req_mapping): + continue + dist = best.get(req.key) if dist is None: # Find the best distribution and add it to the map @@ -854,6 +847,26 @@ class WorkingSet(object): # return list of distros to activate return to_activate + @staticmethod + def _markers_pass(req, extra_req_mapping): + """ + Return False if the req has a marker and fails + evaluation. Otherwise, return True. + + extra_req_mapping is a map of requirements to + extras. + """ + if not req.marker: + return True + + result = [] + if req in extra_req_mapping: + for extra in extra_req_mapping[req] or ['']: + result.append(req.marker.evaluate({'extra': extra})) + else: + result.append(req.marker.evaluate()) + return any(result) + def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True): """Find all activatable distributions in `plugin_env` -- cgit v1.2.1 From a31716f5a86061d7409b8c08154d3b52ff324efd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 5 Apr 2016 13:36:59 +0100 Subject: Remove fallback value until there's something that explains or requires it. --- pkg_resources/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index c3e3e96c..08677719 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -861,7 +861,7 @@ class WorkingSet(object): result = [] if req in extra_req_mapping: - for extra in extra_req_mapping[req] or ['']: + for extra in extra_req_mapping[req]: result.append(req.marker.evaluate({'extra': extra})) else: result.append(req.marker.evaluate()) -- cgit v1.2.1 From 3d8c2245cb09e0db917648f2cf57f99fd10caca1 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 6 Apr 2016 14:49:02 +1000 Subject: Reinstate the or guard in WorkingSet._markers_pass --- pkg_resources/__init__.py | 2 +- pkg_resources/tests/test_resources.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 08677719..c3e3e96c 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -861,7 +861,7 @@ class WorkingSet(object): result = [] if req in extra_req_mapping: - for extra in extra_req_mapping[req]: + for extra in extra_req_mapping[req] or ['']: result.append(req.marker.evaluate({'extra': extra})) else: result.append(req.marker.evaluate()) diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 7f86c797..7907224e 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -186,6 +186,12 @@ class TestDistro: res = ws.resolve(parse_requirements("Foo;python_version>='2'"), ad) assert list(res) == [Foo] + def test_environment_marker_evaluation_called(self): + ws = WorkingSet([]) + req, = parse_requirements("bar;python_version<'4'") + extra_req_mapping = {req: ()} + assert ws._markers_pass(req, extra_req_mapping) == True + def test_marker_evaluation_with_extras(self): """Extras are also evaluated as markers at resolution time.""" ad = pkg_resources.Environment([]) -- cgit v1.2.1 From b1eeba1cd70d6735578cab5e2363c8de653de022 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 6 Apr 2016 16:30:08 +1000 Subject: Stop comparing repr()'s in TestEntryPoint In Python 3, the default order of iterables can not determined, so comparing the repr of objects that include tuples is not static like it is under Python 2. Compare the attributes of EntryPoint instead, making sure to sort .attrs and .extras. Closes: #526 --- pkg_resources/tests/test_resources.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg_resources') diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 7f86c797..f7ddef55 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -382,7 +382,10 @@ class TestEntryPoints: def checkSubMap(self, m): assert len(m) == len(self.submap_expect) for key, ep in self.submap_expect.items(): - assert repr(m.get(key)) == repr(ep) + assert m.get(key).name == ep.name + assert m.get(key).module_name == ep.module_name + assert sorted(m.get(key).attrs) == sorted(ep.attrs) + assert sorted(m.get(key).extras) == sorted(ep.extras) submap_expect = dict( feature1=EntryPoint('feature1', 'somemodule', ['somefunction']), -- cgit v1.2.1 From c7873d38c4478f86864666cd1231877d1183b820 Mon Sep 17 00:00:00 2001 From: riot Date: Thu, 7 Apr 2016 14:39:32 +0200 Subject: This helps finding packages with bad utf Checking hundreds of possibly installed packages manually should NOT be expected of the user ;) --- pkg_resources/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 08677719..8eb697f4 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1859,7 +1859,10 @@ class FileMetadata(EmptyProvider): def get_metadata(self, name): if name=='PKG-INFO': with io.open(self.path, encoding='utf-8') as f: - metadata = f.read() + try: + metadata = f.read() + except UnicodeDecodeError as e: + raise Exception("Bad utf in package: %s - %s" % (self.path, e)) return metadata raise KeyError("No metadata except PKG-INFO is available") -- cgit v1.2.1 From be663b8596fc3e3d02cb5716db1d638788a0230e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 7 Apr 2016 22:05:20 +0100 Subject: Extract _ReqExtras to encapsulate that functionality and decouple it from WorkingSet. --- pkg_resources/__init__.py | 53 +++++++++++++++++++---------------- pkg_resources/tests/test_resources.py | 23 ++++++++++++--- 2 files changed, 48 insertions(+), 28 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index c3e3e96c..d0ba5159 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -791,8 +791,8 @@ class WorkingSet(object): # key -> dist best = {} to_activate = [] - # Map requirement to the extras that require it - extra_req_mapping = {} + + req_extras = _ReqExtras() # Mapping of requirement to set of distributions that required it; # useful for reporting info about conflicts. @@ -805,7 +805,7 @@ class WorkingSet(object): # Ignore cyclic or redundant dependencies continue - if not self._markers_pass(req, extra_req_mapping): + if not req_extras.markers_pass(req): continue dist = best.get(req.key) @@ -840,33 +840,13 @@ class WorkingSet(object): # Register the new requirements needed by req for new_requirement in new_requirements: required_by[new_requirement].add(req.project_name) - extra_req_mapping[new_requirement] = req.extras + req_extras[new_requirement] = req.extras processed[req] = True # return list of distros to activate return to_activate - @staticmethod - def _markers_pass(req, extra_req_mapping): - """ - Return False if the req has a marker and fails - evaluation. Otherwise, return True. - - extra_req_mapping is a map of requirements to - extras. - """ - if not req.marker: - return True - - result = [] - if req in extra_req_mapping: - for extra in extra_req_mapping[req] or ['']: - result.append(req.marker.evaluate({'extra': extra})) - else: - result.append(req.marker.evaluate()) - return any(result) - def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True): """Find all activatable distributions in `plugin_env` @@ -993,6 +973,31 @@ class WorkingSet(object): self.callbacks = callbacks[:] +class _ReqExtras(dict): + """ + Map each requirement to the extras that demanded it. + """ + + def markers_pass(self, req): + """ + Evaluate markers for req against each extra that + demanded it. + + Return False if the req has a marker and fails + evaluation. Otherwise, return True. + """ + if not req.marker: + return True + + result = [] + if req in self: + for extra in self[req] or ['']: + result.append(req.marker.evaluate({'extra': extra})) + else: + result.append(req.marker.evaluate()) + return any(result) + + class Environment(object): """Searchable snapshot of distributions on a search path""" diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 7907224e..acc8dc1e 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -187,10 +187,25 @@ class TestDistro: assert list(res) == [Foo] def test_environment_marker_evaluation_called(self): - ws = WorkingSet([]) - req, = parse_requirements("bar;python_version<'4'") - extra_req_mapping = {req: ()} - assert ws._markers_pass(req, extra_req_mapping) == True + """ + If one package foo requires bar without any extras, + markers should pass for bar. + """ + parent_req, = parse_requirements("foo") + req, = parse_requirements("bar;python_version>='2'") + req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) + assert req_extras.markers_pass(req) + + parent_req, = parse_requirements("foo[]") + req, = parse_requirements("bar;python_version>='2'") + req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) + assert req_extras.markers_pass(req) + + # this is a little awkward; I would want this to fail + parent_req, = parse_requirements("foo") + req, = parse_requirements("bar;python_version>='2' and extra==''") + req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) + assert req_extras.markers_pass(req) def test_marker_evaluation_with_extras(self): """Extras are also evaluated as markers at resolution time.""" -- cgit v1.2.1 From f664385be2051cd135ad52e1563993945e0abe10 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 7 Apr 2016 22:22:58 +0100 Subject: Adjust expectation that 'extra' is not in the marker evaluation if no extras demanded the requirement. --- pkg_resources/__init__.py | 22 ++++++++++++---------- pkg_resources/tests/test_resources.py | 8 +++++--- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index d0ba5159..04064d5a 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -35,6 +35,7 @@ import plistlib import email.parser import tempfile import textwrap +import itertools from pkgutil import get_importer try: @@ -986,16 +987,17 @@ class _ReqExtras(dict): Return False if the req has a marker and fails evaluation. Otherwise, return True. """ - if not req.marker: - return True - - result = [] - if req in self: - for extra in self[req] or ['']: - result.append(req.marker.evaluate({'extra': extra})) - else: - result.append(req.marker.evaluate()) - return any(result) + extra_evals = ( + req.marker.evaluate({'extra': extra}) + for extra in self.get(req, ()) + ) + # set up a late-evaluated simple marker evaluation. + simple_eval = ( + req.marker.evaluate() + for _ in (None,) + ) + evals = itertools.chain(extra_evals, simple_eval) + return not req.marker or any(evals) class Environment(object): diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index acc8dc1e..bd074f22 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -201,11 +201,13 @@ class TestDistro: req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) assert req_extras.markers_pass(req) - # this is a little awkward; I would want this to fail + # extra should not be present in the marker namespace if + # no markers were supplied parent_req, = parse_requirements("foo") - req, = parse_requirements("bar;python_version>='2' and extra==''") + req, = parse_requirements("bar;extra==''") req_extras = pkg_resources._ReqExtras({req: parent_req.extras}) - assert req_extras.markers_pass(req) + 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.""" -- cgit v1.2.1 From 8ce73d4450eb646b80c004e57b82ed9eabe24f35 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 7 Apr 2016 22:24:53 +0100 Subject: Rely on short-circuit in 'or' rather than building a separate iterable. --- pkg_resources/__init__.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 04064d5a..ab48cf7a 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -35,7 +35,6 @@ import plistlib import email.parser import tempfile import textwrap -import itertools from pkgutil import get_importer try: @@ -991,13 +990,7 @@ class _ReqExtras(dict): req.marker.evaluate({'extra': extra}) for extra in self.get(req, ()) ) - # set up a late-evaluated simple marker evaluation. - simple_eval = ( - req.marker.evaluate() - for _ in (None,) - ) - evals = itertools.chain(extra_evals, simple_eval) - return not req.marker or any(evals) + return not req.marker or any(extra_evals) or req.marker.evaluate() class Environment(object): -- cgit v1.2.1 From 84f1525334eb3e6757ee692767301f62536da260 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 7 Apr 2016 23:42:02 +0100 Subject: Instead of reasing a new exception, just augment the existing exception, avoiding any concerns about exception type, but still communicating the context necessary to trace the issue. Ref #537. --- pkg_resources/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index be215ccf..ce4e7755 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1861,8 +1861,11 @@ class FileMetadata(EmptyProvider): with io.open(self.path, encoding='utf-8') as f: try: metadata = f.read() - except UnicodeDecodeError as e: - raise Exception("Bad utf in package: %s - %s" % (self.path, e)) + except UnicodeDecodeError as exc: + # add path context to error message + tmpl = " in {self.path}" + exc.reason += tmpl.format(self=self) + raise return metadata raise KeyError("No metadata except PKG-INFO is available") -- cgit v1.2.1 From dd5caefb987dbd15495047fc653fa71d4667eb43 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 15 Apr 2016 09:03:49 +0200 Subject: Always inject extra into the environment when evaluating markers. Fixes #544. --- pkg_resources/__init__.py | 4 ++-- pkg_resources/tests/test_resources.py | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'pkg_resources') 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([]) -- cgit v1.2.1 From fc2afb512cd077a64b008470e213e624495d6efe Mon Sep 17 00:00:00 2001 From: Geoffrey Sneddon Date: Sat, 23 Apr 2016 23:44:24 +0100 Subject: Update packaging to 16.7 This adds support for the deprecated python_implementation marker which was an undocumented setuptools marker prior to 20.2 in addition to the newer markers. --- pkg_resources/_vendor/packaging/__about__.py | 2 +- pkg_resources/_vendor/packaging/markers.py | 11 ++++++++++- pkg_resources/_vendor/vendored.txt | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'pkg_resources') diff --git a/pkg_resources/_vendor/packaging/__about__.py b/pkg_resources/_vendor/packaging/__about__.py index baa90755..c21a758b 100644 --- a/pkg_resources/_vendor/packaging/__about__.py +++ b/pkg_resources/_vendor/packaging/__about__.py @@ -12,7 +12,7 @@ __title__ = "packaging" __summary__ = "Core utilities for Python packages" __uri__ = "https://github.com/pypa/packaging" -__version__ = "16.6" +__version__ = "16.7" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" diff --git a/pkg_resources/_vendor/packaging/markers.py b/pkg_resources/_vendor/packaging/markers.py index bac852df..c5d29cd9 100644 --- a/pkg_resources/_vendor/packaging/markers.py +++ b/pkg_resources/_vendor/packaging/markers.py @@ -78,9 +78,18 @@ VARIABLE = ( L("platform.version") | # PEP-345 L("platform.machine") | # PEP-345 L("platform.python_implementation") | # PEP-345 + L("python_implementation") | # undocumented setuptools legacy L("extra") ) -VARIABLE.setParseAction(lambda s, l, t: Variable(t[0].replace('.', '_'))) +ALIASES = { + 'os.name': 'os_name', + 'sys.platform': 'sys_platform', + 'platform.version': 'platform_version', + 'platform.machine': 'platform_machine', + 'platform.python_implementation': 'platform_python_implementation', + 'python_implementation': 'platform_python_implementation' +} +VARIABLE.setParseAction(lambda s, l, t: Variable(ALIASES.get(t[0], t[0]))) VERSION_CMP = ( L("===") | diff --git a/pkg_resources/_vendor/vendored.txt b/pkg_resources/_vendor/vendored.txt index 1d03759f..46532c0a 100644 --- a/pkg_resources/_vendor/vendored.txt +++ b/pkg_resources/_vendor/vendored.txt @@ -1,3 +1,3 @@ -packaging==16.6 +packaging==16.7 pyparsing==2.0.6 six==1.10.0 -- cgit v1.2.1