summaryrefslogtreecommitdiff
diff options
authorMatthias Klose <doko@debian.org>2016-11-02 16:12:51 +0100
committergit-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com>2016-11-02 22:21:16 +0000
commitf30d34632bc1e9a7d28c552330c1966729239ddf (patch)
tree7ee3bbd9428853b0e3a4b8f49da2482610bed647
parentb49f698bd6961ecd9e04ab9e0c18ed5ad380d28c (diff)
Imported using git-ubuntu import.
Notes
Notes: * New upstream version.
-rw-r--r--CHANGELOG.rst8
-rw-r--r--PKG-INFO10
-rw-r--r--debian/changelog6
-rw-r--r--docs/development/index.rst4
-rw-r--r--packaging.egg-info/PKG-INFO10
-rw-r--r--packaging/__about__.py2
-rw-r--r--packaging/markers.py24
-rw-r--r--setup.cfg4
-rw-r--r--tests/test_markers.py14
-rw-r--r--tests/test_requirements.py16
10 files changed, 81 insertions, 17 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 45c5daa..caa51cd 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,14 @@
Changelog
---------
+16.8 - 2016-10-29
+~~~~~~~~~~~~~~~~~
+
+* Fix markers that utilize ``in`` so that they render correctly.
+
+* Fix an erroneous test on Python RC releases.
+
+
16.7 - 2016-04-23
~~~~~~~~~~~~~~~~~
diff --git a/PKG-INFO b/PKG-INFO
index d3d0fe6..1656f3e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: packaging
-Version: 16.7
+Version: 16.8
Summary: Core utilities for Python packages
Home-page: https://github.com/pypa/packaging
Author: Donald Stufft and individual contributors
@@ -41,6 +41,14 @@ Description: packaging
Changelog
---------
+ 16.8 - 2016-10-29
+ ~~~~~~~~~~~~~~~~~
+
+ * Fix markers that utilize ``in`` so that they render correctly.
+
+ * Fix an erroneous test on Python RC releases.
+
+
16.7 - 2016-04-23
~~~~~~~~~~~~~~~~~
diff --git a/debian/changelog b/debian/changelog
index f4b3ed6..3c12257 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-packaging (16.8-1) unstable; urgency=medium
+
+ * New upstream version.
+
+ -- Matthias Klose <doko@debian.org> Wed, 02 Nov 2016 16:12:51 +0100
+
python-packaging (16.7-2) unstable; urgency=medium
* Build a pypy-packaging package.
diff --git a/docs/development/index.rst b/docs/development/index.rst
index 3102257..f81799a 100644
--- a/docs/development/index.rst
+++ b/docs/development/index.rst
@@ -14,5 +14,5 @@ bug check out `what to put in your bug report`_.
submitting-patches
reviewing-patches
-.. _`GitHub`: https://github.com/dstufft/packaging
-.. _`what to put in your bug report`: http://www.contribution-guide.org/#what-to-put-in-your-bug-report \ No newline at end of file
+.. _`GitHub`: https://github.com/pypa/packaging
+.. _`what to put in your bug report`: http://www.contribution-guide.org/#what-to-put-in-your-bug-report
diff --git a/packaging.egg-info/PKG-INFO b/packaging.egg-info/PKG-INFO
index d3d0fe6..1656f3e 100644
--- a/packaging.egg-info/PKG-INFO
+++ b/packaging.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: packaging
-Version: 16.7
+Version: 16.8
Summary: Core utilities for Python packages
Home-page: https://github.com/pypa/packaging
Author: Donald Stufft and individual contributors
@@ -41,6 +41,14 @@ Description: packaging
Changelog
---------
+ 16.8 - 2016-10-29
+ ~~~~~~~~~~~~~~~~~
+
+ * Fix markers that utilize ``in`` so that they render correctly.
+
+ * Fix an erroneous test on Python RC releases.
+
+
16.7 - 2016-04-23
~~~~~~~~~~~~~~~~~
diff --git a/packaging/__about__.py b/packaging/__about__.py
index c21a758..95d330e 100644
--- a/packaging/__about__.py
+++ b/packaging/__about__.py
@@ -12,7 +12,7 @@ __title__ = "packaging"
__summary__ = "Core utilities for Python packages"
__uri__ = "https://github.com/pypa/packaging"
-__version__ = "16.7"
+__version__ = "16.8"
__author__ = "Donald Stufft and individual contributors"
__email__ = "donald@stufft.io"
diff --git a/packaging/markers.py b/packaging/markers.py
index d321c7f..5fdf510 100644
--- a/packaging/markers.py
+++ b/packaging/markers.py
@@ -52,13 +52,26 @@ class Node(object):
def __repr__(self):
return "<{0}({1!r})>".format(self.__class__.__name__, str(self))
+ def serialize(self):
+ raise NotImplementedError
+
class Variable(Node):
- pass
+
+ def serialize(self):
+ return str(self)
class Value(Node):
- pass
+
+ def serialize(self):
+ return '"{0}"'.format(self)
+
+
+class Op(Node):
+
+ def serialize(self):
+ return str(self)
VARIABLE = (
@@ -103,6 +116,7 @@ VERSION_CMP = (
)
MARKER_OP = VERSION_CMP | L("not in") | L("in")
+MARKER_OP.setParseAction(lambda s, l, t: Op(t[0]))
MARKER_VALUE = QuotedString("'") | QuotedString('"')
MARKER_VALUE.setParseAction(lambda s, l, t: Value(t[0]))
@@ -149,7 +163,7 @@ def _format_marker(marker, first=True):
else:
return "(" + " ".join(inner) + ")"
elif isinstance(marker, tuple):
- return '{0} {1} "{2}"'.format(*marker)
+ return " ".join([m.serialize() for m in marker])
else:
return marker
@@ -168,13 +182,13 @@ _operators = {
def _eval_op(lhs, op, rhs):
try:
- spec = Specifier("".join([op, rhs]))
+ spec = Specifier("".join([op.serialize(), rhs]))
except InvalidSpecifier:
pass
else:
return spec.contains(lhs)
- oper = _operators.get(op)
+ oper = _operators.get(op.serialize())
if oper is None:
raise UndefinedComparison(
"Undefined {0!r} on {1!r} and {2!r}.".format(op, lhs, rhs)
diff --git a/setup.cfg b/setup.cfg
index 828e8d8..6f08d0e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,7 +2,7 @@
universal = 1
[egg_info]
-tag_svn_revision = 0
-tag_date = 0
tag_build =
+tag_date = 0
+tag_svn_revision = 0
diff --git a/tests/test_markers.py b/tests/test_markers.py
index 82de7c2..0e2d96a 100644
--- a/tests/test_markers.py
+++ b/tests/test_markers.py
@@ -14,7 +14,7 @@ import pytest
from packaging.markers import (
Node, InvalidMarker, UndefinedComparison, UndefinedEnvironmentName, Marker,
- _eval_op, default_environment, format_full_version,
+ default_environment, format_full_version,
)
@@ -58,18 +58,22 @@ class TestNode:
def test_repr(self, value):
assert repr(Node(value)) == "<Node({0!r})>".format(str(value))
+ def test_base_class(self):
+ with pytest.raises(NotImplementedError):
+ Node("cover all the code").serialize()
+
class TestOperatorEvaluation:
def test_prefers_pep440(self):
- assert _eval_op("2.7.10", ">", "2.7.9")
+ assert Marker('"2.7.9" < "foo"').evaluate(dict(foo='2.7.10'))
def test_falls_back_to_python(self):
- assert _eval_op("b", ">", "a")
+ assert Marker('"b" > "a"').evaluate(dict(a='a'))
def test_fails_when_undefined(self):
with pytest.raises(UndefinedComparison):
- _eval_op("2.7.0", "~=", "invalid")
+ Marker("'2.7.0' ~= os_name").evaluate()
FakeVersionInfo = collections.namedtuple(
@@ -129,7 +133,7 @@ class TestDefaultEnvironment:
sys.implementation.version
)
if sys.implementation.version.releaselevel != "final":
- iver = "{0}{1}[0]{2}".format(
+ iver = "{0}{1[0]}{2}".format(
iver,
sys.implementation.version.releaselevel,
sys.implementation.version.serial,
diff --git a/tests/test_requirements.py b/tests/test_requirements.py
index d9e9501..536e712 100644
--- a/tests/test_requirements.py
+++ b/tests/test_requirements.py
@@ -154,3 +154,19 @@ class TestRequirements:
assert isinstance(req.url, str)
assert isinstance(req.specifier, SpecifierSet)
assert req.marker is None
+
+ def test_sys_platform_linux_equal(self):
+ req = Requirement('something>=1.2.3; sys_platform == "foo"')
+
+ assert req.name == 'something'
+ assert req.marker is not None
+ assert req.marker.evaluate(dict(sys_platform="foo")) is True
+ assert req.marker.evaluate(dict(sys_platform="bar")) is False
+
+ def test_sys_platform_linux_in(self):
+ req = Requirement("aviato>=1.2.3; 'f' in sys_platform")
+
+ assert req.name == 'aviato'
+ assert req.marker is not None
+ assert req.marker.evaluate(dict(sys_platform="foo")) is True
+ assert req.marker.evaluate(dict(sys_platform="bar")) is False