Commit cf9402a0 authored by Steve Kowalik's avatar Steve Kowalik

Update to packaging 16.1

parent ba5633b3
...@@ -6,6 +6,6 @@ update-vendored: ...@@ -6,6 +6,6 @@ update-vendored:
rm -rf pkg_resources/_vendor/six* rm -rf pkg_resources/_vendor/six*
rm -rf pkg_resources/_vendor/pyparsing* rm -rf pkg_resources/_vendor/pyparsing*
python3 -m pip install -r pkg_resources/_vendor/vendored.txt -t pkg_resources/_vendor/ python3 -m pip install -r pkg_resources/_vendor/vendored.txt -t pkg_resources/_vendor/
sed -i -e 's/ \(pyparsing|six\)/ pkg_resources.extern.\1/' \ sed -i 's/ \(pyparsing\|six\)/ pkg_resources.extern.\1/' \
pkg_resources/_vendor/packaging/*.py pkg_resources/_vendor/packaging/*.py
rm -rf pkg_resources/_vendor/*.{egg,dist}-info rm -rf pkg_resources/_vendor/*.{egg,dist}-info
...@@ -12,10 +12,10 @@ __title__ = "packaging" ...@@ -12,10 +12,10 @@ __title__ = "packaging"
__summary__ = "Core utilities for Python packages" __summary__ = "Core utilities for Python packages"
__uri__ = "https://github.com/pypa/packaging" __uri__ = "https://github.com/pypa/packaging"
__version__ = "15.4.dev0" __version__ = "16.1"
__author__ = "Donald Stufft and individual contributors" __author__ = "Donald Stufft and individual contributors"
__email__ = "donald@stufft.io" __email__ = "donald@stufft.io"
__license__ = "BSD or Apache License, Version 2.0" __license__ = "BSD or Apache License, Version 2.0"
__copyright__ = "Copyright 2014-2015 %s" % __author__ __copyright__ = "Copyright 2014-2016 %s" % __author__
...@@ -17,7 +17,8 @@ from .specifiers import Specifier, InvalidSpecifier ...@@ -17,7 +17,8 @@ from .specifiers import Specifier, InvalidSpecifier
__all__ = [ __all__ = [
"InvalidMarker", "UndefinedComparison", "Marker", "default_environment", "InvalidMarker", "UndefinedComparison", "UndefinedEnvironmentName",
"Marker", "default_environment",
] ]
...@@ -33,6 +34,13 @@ class UndefinedComparison(ValueError): ...@@ -33,6 +34,13 @@ class UndefinedComparison(ValueError):
""" """
class UndefinedEnvironmentName(ValueError):
"""
A name was attempted to be used that does not exist inside of the
environment.
"""
class Node(object): class Node(object):
def __init__(self, value): def __init__(self, value):
...@@ -116,8 +124,8 @@ def _format_marker(marker, first=True): ...@@ -116,8 +124,8 @@ def _format_marker(marker, first=True):
# where the single item is itself it's own list. In that case we want skip # where the single item is itself it's own list. In that case we want skip
# the rest of this function so that we don't get extraneous () on the # the rest of this function so that we don't get extraneous () on the
# outside. # outside.
if (isinstance(marker, list) and len(marker) == 1 if (isinstance(marker, list) and len(marker) == 1 and
and isinstance(marker[0], (list, tuple))): isinstance(marker[0], (list, tuple))):
return _format_marker(marker[0]) return _format_marker(marker[0])
if isinstance(marker, list): if isinstance(marker, list):
...@@ -161,6 +169,20 @@ def _eval_op(lhs, op, rhs): ...@@ -161,6 +169,20 @@ def _eval_op(lhs, op, rhs):
return oper(lhs, rhs) return oper(lhs, rhs)
_undefined = object()
def _get_env(environment, name):
value = environment.get(name, _undefined)
if value is _undefined:
raise UndefinedEnvironmentName(
"{0!r} does not exist in evaluation environment.".format(name)
)
return value
def _evaluate_markers(markers, environment): def _evaluate_markers(markers, environment):
groups = [[]] groups = [[]]
...@@ -171,11 +193,15 @@ def _evaluate_markers(markers, environment): ...@@ -171,11 +193,15 @@ def _evaluate_markers(markers, environment):
groups[-1].append(_evaluate_markers(marker, environment)) groups[-1].append(_evaluate_markers(marker, environment))
elif isinstance(marker, tuple): elif isinstance(marker, tuple):
lhs, op, rhs = marker lhs, op, rhs = marker
if isinstance(lhs, Variable): if isinstance(lhs, Variable):
value = _eval_op(environment[lhs.value], op, rhs.value) lhs_value = _get_env(environment, lhs.value)
rhs_value = rhs.value
else: else:
value = _eval_op(lhs.value, op, environment[rhs.value]) lhs_value = lhs.value
groups[-1].append(value) rhs_value = _get_env(environment, rhs.value)
groups[-1].append(_eval_op(lhs_value, op, rhs_value))
else: else:
assert marker in ["and", "or"] assert marker in ["and", "or"]
if marker == "or": if marker == "or":
...@@ -220,12 +246,10 @@ class Marker(object): ...@@ -220,12 +246,10 @@ class Marker(object):
def __init__(self, marker): def __init__(self, marker):
try: try:
self._markers = _coerce_parse_result(MARKER.parseString(marker)) self._markers = _coerce_parse_result(MARKER.parseString(marker))
except ParseException: except ParseException as e:
self._markers = None err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
marker, marker[e.loc:e.loc + 8])
# We do this because we can't do raise ... from None in Python 2.x raise InvalidMarker(err_str)
if self._markers is None:
raise InvalidMarker("Invalid marker: {0!r}".format(marker))
def __str__(self): def __str__(self):
return _format_marker(self._markers) return _format_marker(self._markers)
......
...@@ -102,7 +102,7 @@ class Requirement(object): ...@@ -102,7 +102,7 @@ class Requirement(object):
self.url = req.url self.url = req.url
else: else:
self.url = None self.url = None
self.extras = req.extras.asList() if req.extras else [] self.extras = set(req.extras.asList() if req.extras else [])
self.specifier = SpecifierSet(req.specifier) self.specifier = SpecifierSet(req.specifier)
self.marker = req.marker if req.marker else None self.marker = req.marker if req.marker else None
......
...@@ -194,8 +194,8 @@ class _IndividualSpecifier(BaseSpecifier): ...@@ -194,8 +194,8 @@ class _IndividualSpecifier(BaseSpecifier):
# If our version is a prerelease, and we were not set to allow # If our version is a prerelease, and we were not set to allow
# prereleases, then we'll store it for later incase nothing # prereleases, then we'll store it for later incase nothing
# else matches this specifier. # else matches this specifier.
if (parsed_version.is_prerelease if (parsed_version.is_prerelease and not
and not (prereleases or self.prereleases)): (prereleases or self.prereleases)):
found_prereleases.append(version) found_prereleases.append(version)
# Either this is not a prerelease, or we should have been # Either this is not a prerelease, or we should have been
# accepting prereleases from the begining. # accepting prereleases from the begining.
...@@ -395,8 +395,8 @@ class Specifier(_IndividualSpecifier): ...@@ -395,8 +395,8 @@ class Specifier(_IndividualSpecifier):
prefix = ".".join( prefix = ".".join(
list( list(
itertools.takewhile( itertools.takewhile(
lambda x: (not x.startswith("post") lambda x: (not x.startswith("post") and not
and not x.startswith("dev")), x.startswith("dev")),
_version_split(spec), _version_split(spec),
) )
)[:-1] )[:-1]
...@@ -405,13 +405,15 @@ class Specifier(_IndividualSpecifier): ...@@ -405,13 +405,15 @@ class Specifier(_IndividualSpecifier):
# Add the prefix notation to the end of our string # Add the prefix notation to the end of our string
prefix += ".*" prefix += ".*"
return (self._get_operator(">=")(prospective, spec) return (self._get_operator(">=")(prospective, spec) and
and self._get_operator("==")(prospective, prefix)) self._get_operator("==")(prospective, prefix))
@_require_version_compare @_require_version_compare
def _compare_equal(self, prospective, spec): def _compare_equal(self, prospective, spec):
# We need special logic to handle prefix matching # We need special logic to handle prefix matching
if spec.endswith(".*"): if spec.endswith(".*"):
# In the case of prefix matching we want to ignore local segment.
prospective = Version(prospective.public)
# Split the spec out by dots, and pretend that there is an implicit # Split the spec out by dots, and pretend that there is an implicit
# dot in between a release segment and a pre-release segment. # dot in between a release segment and a pre-release segment.
spec = _version_split(spec[:-2]) # Remove the trailing .* spec = _version_split(spec[:-2]) # Remove the trailing .*
...@@ -563,8 +565,8 @@ def _pad_version(left, right): ...@@ -563,8 +565,8 @@ def _pad_version(left, right):
right_split.append(list(itertools.takewhile(lambda x: x.isdigit(), right))) right_split.append(list(itertools.takewhile(lambda x: x.isdigit(), right)))
# Get the rest of our versions # Get the rest of our versions
left_split.append(left[len(left_split):]) left_split.append(left[len(left_split[0]):])
right_split.append(left[len(right_split):]) right_split.append(right[len(right_split[0]):])
# Insert our padding # Insert our padding
left_split.insert( left_split.insert(
......
packaging==15.3 packaging==16.1
pyparsing==2.0.6 pyparsing==2.0.6
six==1.10.0 six==1.10.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment