add py3.5 netifaces
This commit is contained in:
parent
717a291e19
commit
86cc34eed3
228 changed files with 1616 additions and 65914 deletions
|
|
@ -75,8 +75,6 @@ except ImportError:
|
|||
from pkg_resources.extern import packaging
|
||||
__import__('pkg_resources.extern.packaging.version')
|
||||
__import__('pkg_resources.extern.packaging.specifiers')
|
||||
__import__('pkg_resources.extern.packaging.requirements')
|
||||
__import__('pkg_resources.extern.packaging.markers')
|
||||
|
||||
|
||||
if (3, 0) < sys.version_info < (3, 3):
|
||||
|
|
@ -1387,34 +1385,202 @@ def to_filename(name):
|
|||
return name.replace('-','_')
|
||||
|
||||
|
||||
def invalid_marker(text):
|
||||
"""
|
||||
Validate text as a PEP 508 environment marker; return an exception
|
||||
if invalid or False otherwise.
|
||||
"""
|
||||
try:
|
||||
evaluate_marker(text)
|
||||
except SyntaxError as e:
|
||||
e.filename = None
|
||||
e.lineno = None
|
||||
return e
|
||||
return False
|
||||
class MarkerEvaluation(object):
|
||||
values = {
|
||||
'os_name': lambda: os.name,
|
||||
'sys_platform': lambda: sys.platform,
|
||||
'python_full_version': platform.python_version,
|
||||
'python_version': lambda: platform.python_version()[:3],
|
||||
'platform_version': platform.version,
|
||||
'platform_machine': platform.machine,
|
||||
'platform_python_implementation': platform.python_implementation,
|
||||
'python_implementation': platform.python_implementation,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def is_invalid_marker(cls, text):
|
||||
"""
|
||||
Validate text as a PEP 426 environment marker; return an exception
|
||||
if invalid or False otherwise.
|
||||
"""
|
||||
try:
|
||||
cls.evaluate_marker(text)
|
||||
except SyntaxError as e:
|
||||
return cls.normalize_exception(e)
|
||||
return False
|
||||
|
||||
def evaluate_marker(text, extra=None):
|
||||
"""
|
||||
Evaluate a PEP 508 environment marker.
|
||||
Return a boolean indicating the marker result in this environment.
|
||||
Raise SyntaxError if marker is invalid.
|
||||
@staticmethod
|
||||
def normalize_exception(exc):
|
||||
"""
|
||||
Given a SyntaxError from a marker evaluation, normalize the error
|
||||
message:
|
||||
- Remove indications of filename and line number.
|
||||
- Replace platform-specific error messages with standard error
|
||||
messages.
|
||||
"""
|
||||
subs = {
|
||||
'unexpected EOF while parsing': 'invalid syntax',
|
||||
'parenthesis is never closed': 'invalid syntax',
|
||||
}
|
||||
exc.filename = None
|
||||
exc.lineno = None
|
||||
exc.msg = subs.get(exc.msg, exc.msg)
|
||||
return exc
|
||||
|
||||
This implementation uses the 'pyparsing' module.
|
||||
"""
|
||||
try:
|
||||
marker = packaging.markers.Marker(text)
|
||||
return marker.evaluate()
|
||||
except packaging.markers.InvalidMarker as e:
|
||||
raise SyntaxError(e)
|
||||
@classmethod
|
||||
def and_test(cls, nodelist):
|
||||
# MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
|
||||
items = [
|
||||
cls.interpret(nodelist[i])
|
||||
for i in range(1, len(nodelist), 2)
|
||||
]
|
||||
return functools.reduce(operator.and_, items)
|
||||
|
||||
@classmethod
|
||||
def test(cls, nodelist):
|
||||
# MUST NOT short-circuit evaluation, or invalid syntax can be skipped!
|
||||
items = [
|
||||
cls.interpret(nodelist[i])
|
||||
for i in range(1, len(nodelist), 2)
|
||||
]
|
||||
return functools.reduce(operator.or_, items)
|
||||
|
||||
@classmethod
|
||||
def atom(cls, nodelist):
|
||||
t = nodelist[1][0]
|
||||
if t == token.LPAR:
|
||||
if nodelist[2][0] == token.RPAR:
|
||||
raise SyntaxError("Empty parentheses")
|
||||
return cls.interpret(nodelist[2])
|
||||
msg = "Language feature not supported in environment markers"
|
||||
raise SyntaxError(msg)
|
||||
|
||||
@classmethod
|
||||
def comparison(cls, nodelist):
|
||||
if len(nodelist) > 4:
|
||||
msg = "Chained comparison not allowed in environment markers"
|
||||
raise SyntaxError(msg)
|
||||
comp = nodelist[2][1]
|
||||
cop = comp[1]
|
||||
if comp[0] == token.NAME:
|
||||
if len(nodelist[2]) == 3:
|
||||
if cop == 'not':
|
||||
cop = 'not in'
|
||||
else:
|
||||
cop = 'is not'
|
||||
try:
|
||||
cop = cls.get_op(cop)
|
||||
except KeyError:
|
||||
msg = repr(cop) + " operator not allowed in environment markers"
|
||||
raise SyntaxError(msg)
|
||||
return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3]))
|
||||
|
||||
@classmethod
|
||||
def get_op(cls, op):
|
||||
ops = {
|
||||
symbol.test: cls.test,
|
||||
symbol.and_test: cls.and_test,
|
||||
symbol.atom: cls.atom,
|
||||
symbol.comparison: cls.comparison,
|
||||
'not in': lambda x, y: x not in y,
|
||||
'in': lambda x, y: x in y,
|
||||
'==': operator.eq,
|
||||
'!=': operator.ne,
|
||||
'<': operator.lt,
|
||||
'>': operator.gt,
|
||||
'<=': operator.le,
|
||||
'>=': operator.ge,
|
||||
}
|
||||
if hasattr(symbol, 'or_test'):
|
||||
ops[symbol.or_test] = cls.test
|
||||
return ops[op]
|
||||
|
||||
@classmethod
|
||||
def evaluate_marker(cls, text, extra=None):
|
||||
"""
|
||||
Evaluate a PEP 426 environment marker on CPython 2.4+.
|
||||
Return a boolean indicating the marker result in this environment.
|
||||
Raise SyntaxError if marker is invalid.
|
||||
|
||||
This implementation uses the 'parser' module, which is not implemented
|
||||
on
|
||||
Jython and has been superseded by the 'ast' module in Python 2.6 and
|
||||
later.
|
||||
"""
|
||||
return cls.interpret(parser.expr(text).totuple(1)[1])
|
||||
|
||||
@staticmethod
|
||||
def _translate_metadata2(env):
|
||||
"""
|
||||
Markerlib implements Metadata 1.2 (PEP 345) environment markers.
|
||||
Translate the variables to Metadata 2.0 (PEP 426).
|
||||
"""
|
||||
return dict(
|
||||
(key.replace('.', '_'), value)
|
||||
for key, value in env.items()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _markerlib_evaluate(cls, text):
|
||||
"""
|
||||
Evaluate a PEP 426 environment marker using markerlib.
|
||||
Return a boolean indicating the marker result in this environment.
|
||||
Raise SyntaxError if marker is invalid.
|
||||
"""
|
||||
import _markerlib
|
||||
|
||||
env = cls._translate_metadata2(_markerlib.default_environment())
|
||||
try:
|
||||
result = _markerlib.interpret(text, env)
|
||||
except NameError as e:
|
||||
raise SyntaxError(e.args[0])
|
||||
return result
|
||||
|
||||
if 'parser' not in globals():
|
||||
# Fall back to less-complete _markerlib implementation if 'parser' module
|
||||
# is not available.
|
||||
evaluate_marker = _markerlib_evaluate
|
||||
|
||||
@classmethod
|
||||
def interpret(cls, nodelist):
|
||||
while len(nodelist)==2: nodelist = nodelist[1]
|
||||
try:
|
||||
op = cls.get_op(nodelist[0])
|
||||
except KeyError:
|
||||
raise SyntaxError("Comparison or logical expression expected")
|
||||
return op(nodelist)
|
||||
|
||||
@classmethod
|
||||
def evaluate(cls, nodelist):
|
||||
while len(nodelist)==2: nodelist = nodelist[1]
|
||||
kind = nodelist[0]
|
||||
name = nodelist[1]
|
||||
if kind==token.NAME:
|
||||
try:
|
||||
op = cls.values[name]
|
||||
except KeyError:
|
||||
raise SyntaxError("Unknown name %r" % name)
|
||||
return op()
|
||||
if kind==token.STRING:
|
||||
s = nodelist[1]
|
||||
if not cls._safe_string(s):
|
||||
raise SyntaxError(
|
||||
"Only plain strings allowed in environment markers")
|
||||
return s[1:-1]
|
||||
msg = "Language feature not supported in environment markers"
|
||||
raise SyntaxError(msg)
|
||||
|
||||
@staticmethod
|
||||
def _safe_string(cand):
|
||||
return (
|
||||
cand[:1] in "'\"" and
|
||||
not cand.startswith('"""') and
|
||||
not cand.startswith("'''") and
|
||||
'\\' not in cand
|
||||
)
|
||||
|
||||
invalid_marker = MarkerEvaluation.is_invalid_marker
|
||||
evaluate_marker = MarkerEvaluation.evaluate_marker
|
||||
|
||||
class NullProvider:
|
||||
"""Try to implement resources and metadata for arbitrary PEP 302 loaders"""
|
||||
|
|
@ -2148,6 +2314,18 @@ def yield_lines(strs):
|
|||
for s in yield_lines(ss):
|
||||
yield s
|
||||
|
||||
# whitespace and comment
|
||||
LINE_END = re.compile(r"\s*(#.*)?$").match
|
||||
# line continuation
|
||||
CONTINUE = re.compile(r"\s*\\\s*(#.*)?$").match
|
||||
# Distribution or extra
|
||||
DISTRO = re.compile(r"\s*((\w|[-.])+)").match
|
||||
# ver. info
|
||||
VERSION = re.compile(r"\s*(<=?|>=?|===?|!=|~=)\s*((\w|[-.*_!+])+)").match
|
||||
# comma between items
|
||||
COMMA = re.compile(r"\s*,").match
|
||||
OBRACKET = re.compile(r"\s*\[").match
|
||||
CBRACKET = re.compile(r"\s*\]").match
|
||||
MODULE = re.compile(r"\w+(\.\w+)*$").match
|
||||
EGG_NAME = re.compile(
|
||||
r"""
|
||||
|
|
@ -2686,18 +2864,34 @@ class DistInfoDistribution(Distribution):
|
|||
self.__dep_map = self._compute_dependencies()
|
||||
return self.__dep_map
|
||||
|
||||
def _preparse_requirement(self, requires_dist):
|
||||
"""Convert 'Foobar (1); baz' to ('Foobar ==1', 'baz')
|
||||
Split environment marker, add == prefix to version specifiers as
|
||||
necessary, and remove parenthesis.
|
||||
"""
|
||||
parts = requires_dist.split(';', 1) + ['']
|
||||
distvers = parts[0].strip()
|
||||
mark = parts[1].strip()
|
||||
distvers = re.sub(self.EQEQ, r"\1==\2\3", distvers)
|
||||
distvers = distvers.replace('(', '').replace(')', '')
|
||||
return (distvers, mark)
|
||||
|
||||
def _compute_dependencies(self):
|
||||
"""Recompute this distribution's dependencies."""
|
||||
from _markerlib import compile as compile_marker
|
||||
dm = self.__dep_map = {None: []}
|
||||
|
||||
reqs = []
|
||||
# Including any condition expressions
|
||||
for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
|
||||
reqs.extend(parse_requirements(req))
|
||||
distvers, mark = self._preparse_requirement(req)
|
||||
parsed = next(parse_requirements(distvers))
|
||||
parsed.marker_fn = compile_marker(mark)
|
||||
reqs.append(parsed)
|
||||
|
||||
def reqs_for_extra(extra):
|
||||
for req in reqs:
|
||||
if not req.marker or req.marker.evaluate({'extra': extra}):
|
||||
if req.marker_fn(override={'extra':extra}):
|
||||
yield req
|
||||
|
||||
common = frozenset(reqs_for_extra(None))
|
||||
|
|
@ -2743,38 +2937,85 @@ def parse_requirements(strs):
|
|||
# create a steppable iterator, so we can handle \-continuations
|
||||
lines = iter(yield_lines(strs))
|
||||
|
||||
def scan_list(ITEM, TERMINATOR, line, p, groups, item_name):
|
||||
|
||||
items = []
|
||||
|
||||
while not TERMINATOR(line, p):
|
||||
if CONTINUE(line, p):
|
||||
try:
|
||||
line = next(lines)
|
||||
p = 0
|
||||
except StopIteration:
|
||||
msg = "\\ must not appear on the last nonblank line"
|
||||
raise RequirementParseError(msg)
|
||||
|
||||
match = ITEM(line, p)
|
||||
if not match:
|
||||
msg = "Expected " + item_name + " in"
|
||||
raise RequirementParseError(msg, line, "at", line[p:])
|
||||
|
||||
items.append(match.group(*groups))
|
||||
p = match.end()
|
||||
|
||||
match = COMMA(line, p)
|
||||
if match:
|
||||
# skip the comma
|
||||
p = match.end()
|
||||
elif not TERMINATOR(line, p):
|
||||
msg = "Expected ',' or end-of-list in"
|
||||
raise RequirementParseError(msg, line, "at", line[p:])
|
||||
|
||||
match = TERMINATOR(line, p)
|
||||
# skip the terminator, if any
|
||||
if match:
|
||||
p = match.end()
|
||||
return line, p, items
|
||||
|
||||
for line in lines:
|
||||
# Drop comments -- a hash without a space may be in a URL.
|
||||
if ' #' in line:
|
||||
line = line[:line.find(' #')]
|
||||
# If there is a line continuation, drop it, and append the next line.
|
||||
if line.endswith('\\'):
|
||||
line = line[:-2].strip()
|
||||
line += next(lines)
|
||||
yield Requirement(line)
|
||||
match = DISTRO(line)
|
||||
if not match:
|
||||
raise RequirementParseError("Missing distribution spec", line)
|
||||
project_name = match.group(1)
|
||||
p = match.end()
|
||||
extras = []
|
||||
|
||||
match = OBRACKET(line, p)
|
||||
if match:
|
||||
p = match.end()
|
||||
line, p, extras = scan_list(
|
||||
DISTRO, CBRACKET, line, p, (1,), "'extra' name"
|
||||
)
|
||||
|
||||
line, p, specs = scan_list(VERSION, LINE_END, line, p, (1, 2),
|
||||
"version spec")
|
||||
specs = [(op, val) for op, val in specs]
|
||||
yield Requirement(project_name, specs, extras)
|
||||
|
||||
|
||||
class Requirement(packaging.requirements.Requirement):
|
||||
def __init__(self, requirement_string):
|
||||
class Requirement:
|
||||
def __init__(self, project_name, specs, extras):
|
||||
"""DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!"""
|
||||
try:
|
||||
super(Requirement, self).__init__(requirement_string)
|
||||
except packaging.requirements.InvalidRequirement as e:
|
||||
raise RequirementParseError(str(e))
|
||||
self.unsafe_name = self.name
|
||||
project_name = safe_name(self.name)
|
||||
self.unsafe_name, project_name = project_name, safe_name(project_name)
|
||||
self.project_name, self.key = project_name, project_name.lower()
|
||||
self.specs = [
|
||||
(spec.operator, spec.version) for spec in self.specifier]
|
||||
self.extras = tuple(map(safe_extra, self.extras))
|
||||
self.specifier = packaging.specifiers.SpecifierSet(
|
||||
",".join(["".join([x, y]) for x, y in specs])
|
||||
)
|
||||
self.specs = specs
|
||||
self.extras = tuple(map(safe_extra, extras))
|
||||
self.hashCmp = (
|
||||
self.key,
|
||||
self.specifier,
|
||||
frozenset(self.extras),
|
||||
str(self.marker) if self.marker else None,
|
||||
)
|
||||
self.__hash = hash(self.hashCmp)
|
||||
|
||||
def __str__(self):
|
||||
extras = ','.join(self.extras)
|
||||
if extras:
|
||||
extras = '[%s]' % extras
|
||||
return '%s%s%s' % (self.project_name, extras, self.specifier)
|
||||
|
||||
def __eq__(self, other):
|
||||
return (
|
||||
isinstance(other, Requirement) and
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
# Copyright 2014 Donald Stufft
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__all__ = [
|
||||
|
|
@ -12,10 +22,10 @@ __title__ = "packaging"
|
|||
__summary__ = "Core utilities for Python packages"
|
||||
__uri__ = "https://github.com/pypa/packaging"
|
||||
|
||||
__version__ = "16.5"
|
||||
__version__ = "15.3"
|
||||
|
||||
__author__ = "Donald Stufft and individual contributors"
|
||||
__author__ = "Donald Stufft"
|
||||
__email__ = "donald@stufft.io"
|
||||
|
||||
__license__ = "BSD or Apache License, Version 2.0"
|
||||
__copyright__ = "Copyright 2014-2016 %s" % __author__
|
||||
__license__ = "Apache License, Version 2.0"
|
||||
__copyright__ = "Copyright 2014 %s" % __author__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
# Copyright 2014 Donald Stufft
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from .__about__ import (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
# Copyright 2014 Donald Stufft
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
# Copyright 2014 Donald Stufft
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
# Copyright 2014 Donald Stufft
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import abc
|
||||
|
|
@ -194,8 +204,8 @@ class _IndividualSpecifier(BaseSpecifier):
|
|||
# If our version is a prerelease, and we were not set to allow
|
||||
# prereleases, then we'll store it for later incase nothing
|
||||
# else matches this specifier.
|
||||
if (parsed_version.is_prerelease and not
|
||||
(prereleases or self.prereleases)):
|
||||
if (parsed_version.is_prerelease
|
||||
and not (prereleases or self.prereleases)):
|
||||
found_prereleases.append(version)
|
||||
# Either this is not a prerelease, or we should have been
|
||||
# accepting prereleases from the begining.
|
||||
|
|
@ -213,23 +223,23 @@ class _IndividualSpecifier(BaseSpecifier):
|
|||
|
||||
class LegacySpecifier(_IndividualSpecifier):
|
||||
|
||||
_regex_str = (
|
||||
_regex = re.compile(
|
||||
r"""
|
||||
^
|
||||
\s*
|
||||
(?P<operator>(==|!=|<=|>=|<|>))
|
||||
\s*
|
||||
(?P<version>
|
||||
[^,;\s)]* # Since this is a "legacy" specifier, and the version
|
||||
# string can be just about anything, we match everything
|
||||
# except for whitespace, a semi-colon for marker support,
|
||||
# a closing paren since versions can be enclosed in
|
||||
# them, and a comma since it's a version separator.
|
||||
[^\s]* # We just match everything, except for whitespace since this
|
||||
# is a "legacy" specifier and the version string can be just
|
||||
# about anything.
|
||||
)
|
||||
"""
|
||||
\s*
|
||||
$
|
||||
""",
|
||||
re.VERBOSE | re.IGNORECASE,
|
||||
)
|
||||
|
||||
_regex = re.compile(
|
||||
r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
_operators = {
|
||||
"==": "equal",
|
||||
"!=": "not_equal",
|
||||
|
|
@ -274,8 +284,10 @@ def _require_version_compare(fn):
|
|||
|
||||
class Specifier(_IndividualSpecifier):
|
||||
|
||||
_regex_str = (
|
||||
_regex = re.compile(
|
||||
r"""
|
||||
^
|
||||
\s*
|
||||
(?P<operator>(~=|==|!=|<=|>=|<|>|===))
|
||||
(?P<version>
|
||||
(?:
|
||||
|
|
@ -366,12 +378,12 @@ class Specifier(_IndividualSpecifier):
|
|||
(?:[-_\.]?dev[-_\.]?[0-9]*)? # dev release
|
||||
)
|
||||
)
|
||||
"""
|
||||
\s*
|
||||
$
|
||||
""",
|
||||
re.VERBOSE | re.IGNORECASE,
|
||||
)
|
||||
|
||||
_regex = re.compile(
|
||||
r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
_operators = {
|
||||
"~=": "compatible",
|
||||
"==": "equal",
|
||||
|
|
@ -397,8 +409,8 @@ class Specifier(_IndividualSpecifier):
|
|||
prefix = ".".join(
|
||||
list(
|
||||
itertools.takewhile(
|
||||
lambda x: (not x.startswith("post") and not
|
||||
x.startswith("dev")),
|
||||
lambda x: (not x.startswith("post")
|
||||
and not x.startswith("dev")),
|
||||
_version_split(spec),
|
||||
)
|
||||
)[:-1]
|
||||
|
|
@ -407,15 +419,13 @@ class Specifier(_IndividualSpecifier):
|
|||
# Add the prefix notation to the end of our string
|
||||
prefix += ".*"
|
||||
|
||||
return (self._get_operator(">=")(prospective, spec) and
|
||||
self._get_operator("==")(prospective, prefix))
|
||||
return (self._get_operator(">=")(prospective, spec)
|
||||
and self._get_operator("==")(prospective, prefix))
|
||||
|
||||
@_require_version_compare
|
||||
def _compare_equal(self, prospective, spec):
|
||||
# We need special logic to handle prefix matching
|
||||
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
|
||||
# dot in between a release segment and a pre-release segment.
|
||||
spec = _version_split(spec[:-2]) # Remove the trailing .*
|
||||
|
|
@ -567,8 +577,8 @@ def _pad_version(left, right):
|
|||
right_split.append(list(itertools.takewhile(lambda x: x.isdigit(), right)))
|
||||
|
||||
# Get the rest of our versions
|
||||
left_split.append(left[len(left_split[0]):])
|
||||
right_split.append(right[len(right_split[0]):])
|
||||
left_split.append(left[len(left_split):])
|
||||
right_split.append(left[len(right_split):])
|
||||
|
||||
# Insert our padding
|
||||
left_split.insert(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# This file is dual licensed under the terms of the Apache License, Version
|
||||
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
|
||||
# for complete details.
|
||||
# Copyright 2014 Donald Stufft
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import collections
|
||||
|
|
|
|||
|
|
@ -67,5 +67,5 @@ class VendorImporter:
|
|||
if self not in sys.meta_path:
|
||||
sys.meta_path.append(self)
|
||||
|
||||
names = 'packaging', 'pyparsing', 'six'
|
||||
names = 'packaging', 'six'
|
||||
VendorImporter(__name__, names).install()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue