Eliminado venv y www del repositorio, agrege un requirements igual
This commit is contained in:
@@ -55,7 +55,7 @@ except NameError:
|
||||
FileExistsError = OSError
|
||||
|
||||
from pkg_resources.extern import six
|
||||
from pkg_resources.extern.six.moves import urllib, map, filter
|
||||
from pkg_resources.extern.six.moves import map, filter
|
||||
|
||||
# capture these to bypass sandboxing
|
||||
from os import utime
|
||||
@@ -76,7 +76,6 @@ try:
|
||||
except ImportError:
|
||||
importlib_machinery = None
|
||||
|
||||
from . import py31compat
|
||||
from pkg_resources.extern import appdirs
|
||||
from pkg_resources.extern import packaging
|
||||
__import__('pkg_resources.extern.packaging.version')
|
||||
@@ -88,8 +87,8 @@ __import__('pkg_resources.extern.packaging.markers')
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
if (3, 0) < sys.version_info < (3, 4):
|
||||
raise RuntimeError("Python 3.4 or later is required")
|
||||
if (3, 0) < sys.version_info < (3, 5):
|
||||
raise RuntimeError("Python 3.5 or later is required")
|
||||
|
||||
if six.PY2:
|
||||
# Those builtin exceptions are only defined in Python 3
|
||||
@@ -178,10 +177,10 @@ def get_supported_platform():
|
||||
"""Return this platform's maximum compatible version.
|
||||
|
||||
distutils.util.get_platform() normally reports the minimum version
|
||||
of Mac OS X that would be required to *use* extensions produced by
|
||||
of macOS that would be required to *use* extensions produced by
|
||||
distutils. But what we want when checking compatibility is to know the
|
||||
version of Mac OS X that we are *running*. To allow usage of packages that
|
||||
explicitly require a newer version of Mac OS X, we must also know the
|
||||
version of macOS that we are *running*. To allow usage of packages that
|
||||
explicitly require a newer version of macOS, we must also know the
|
||||
current version of the OS.
|
||||
|
||||
If this condition occurs for any other platform with a version in its
|
||||
@@ -191,9 +190,9 @@ def get_supported_platform():
|
||||
m = macosVersionString.match(plat)
|
||||
if m is not None and sys.platform == "darwin":
|
||||
try:
|
||||
plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3))
|
||||
plat = 'macosx-%s-%s' % ('.'.join(_macos_vers()[:2]), m.group(3))
|
||||
except ValueError:
|
||||
# not Mac OS X
|
||||
# not macOS
|
||||
pass
|
||||
return plat
|
||||
|
||||
@@ -333,7 +332,7 @@ class UnknownExtra(ResolutionError):
|
||||
|
||||
_provider_factories = {}
|
||||
|
||||
PY_MAJOR = sys.version[:3]
|
||||
PY_MAJOR = '{}.{}'.format(*sys.version_info)
|
||||
EGG_DIST = 3
|
||||
BINARY_DIST = 2
|
||||
SOURCE_DIST = 1
|
||||
@@ -364,7 +363,7 @@ def get_provider(moduleOrReq):
|
||||
return _find_adapter(_provider_factories, loader)(module)
|
||||
|
||||
|
||||
def _macosx_vers(_cache=[]):
|
||||
def _macos_vers(_cache=[]):
|
||||
if not _cache:
|
||||
version = platform.mac_ver()[0]
|
||||
# fallback for MacPorts
|
||||
@@ -380,7 +379,7 @@ def _macosx_vers(_cache=[]):
|
||||
return _cache[0]
|
||||
|
||||
|
||||
def _macosx_arch(machine):
|
||||
def _macos_arch(machine):
|
||||
return {'PowerPC': 'ppc', 'Power_Macintosh': 'ppc'}.get(machine, machine)
|
||||
|
||||
|
||||
@@ -388,18 +387,18 @@ def get_build_platform():
|
||||
"""Return this platform's string for platform-specific distributions
|
||||
|
||||
XXX Currently this is the same as ``distutils.util.get_platform()``, but it
|
||||
needs some hacks for Linux and Mac OS X.
|
||||
needs some hacks for Linux and macOS.
|
||||
"""
|
||||
from sysconfig import get_platform
|
||||
|
||||
plat = get_platform()
|
||||
if sys.platform == "darwin" and not plat.startswith('macosx-'):
|
||||
try:
|
||||
version = _macosx_vers()
|
||||
version = _macos_vers()
|
||||
machine = os.uname()[4].replace(" ", "_")
|
||||
return "macosx-%d.%d-%s" % (
|
||||
int(version[0]), int(version[1]),
|
||||
_macosx_arch(machine),
|
||||
_macos_arch(machine),
|
||||
)
|
||||
except ValueError:
|
||||
# if someone is running a non-Mac darwin system, this will fall
|
||||
@@ -425,7 +424,7 @@ def compatible_platforms(provided, required):
|
||||
# easy case
|
||||
return True
|
||||
|
||||
# Mac OS X special cases
|
||||
# macOS special cases
|
||||
reqMac = macosVersionString.match(required)
|
||||
if reqMac:
|
||||
provMac = macosVersionString.match(provided)
|
||||
@@ -434,7 +433,7 @@ def compatible_platforms(provided, required):
|
||||
if not provMac:
|
||||
# this is backwards compatibility for packages built before
|
||||
# setuptools 0.6. All packages built after this point will
|
||||
# use the new macosx designation.
|
||||
# use the new macOS designation.
|
||||
provDarwin = darwinVersionString.match(provided)
|
||||
if provDarwin:
|
||||
dversion = int(provDarwin.group(1))
|
||||
@@ -442,7 +441,7 @@ def compatible_platforms(provided, required):
|
||||
if dversion == 7 and macosversion >= "10.3" or \
|
||||
dversion == 8 and macosversion >= "10.4":
|
||||
return True
|
||||
# egg isn't macosx or legacy darwin
|
||||
# egg isn't macOS or legacy darwin
|
||||
return False
|
||||
|
||||
# are they the same major version and machine type?
|
||||
@@ -1234,12 +1233,13 @@ class ResourceManager:
|
||||
mode = os.stat(path).st_mode
|
||||
if mode & stat.S_IWOTH or mode & stat.S_IWGRP:
|
||||
msg = (
|
||||
"%s is writable by group/others and vulnerable to attack "
|
||||
"when "
|
||||
"used with get_resource_filename. Consider a more secure "
|
||||
"Extraction path is writable by group/others "
|
||||
"and vulnerable to attack when "
|
||||
"used with get_resource_filename ({path}). "
|
||||
"Consider a more secure "
|
||||
"location (set with .set_extraction_path or the "
|
||||
"PYTHON_EGG_CACHE environment variable)." % path
|
||||
)
|
||||
"PYTHON_EGG_CACHE environment variable)."
|
||||
).format(**locals())
|
||||
warnings.warn(msg, UserWarning)
|
||||
|
||||
def postprocess(self, tempname, filename):
|
||||
@@ -1377,7 +1377,7 @@ def evaluate_marker(text, extra=None):
|
||||
marker = packaging.markers.Marker(text)
|
||||
return marker.evaluate()
|
||||
except packaging.markers.InvalidMarker as e:
|
||||
raise SyntaxError(e)
|
||||
raise SyntaxError(e) from e
|
||||
|
||||
|
||||
class NullProvider:
|
||||
@@ -1457,7 +1457,8 @@ class NullProvider:
|
||||
script_filename = self._fn(self.egg_info, script)
|
||||
namespace['__file__'] = script_filename
|
||||
if os.path.exists(script_filename):
|
||||
source = open(script_filename).read()
|
||||
with open(script_filename) as fid:
|
||||
source = fid.read()
|
||||
code = compile(source, script_filename, 'exec')
|
||||
exec(code, namespace, namespace)
|
||||
else:
|
||||
@@ -1575,6 +1576,17 @@ is not allowed.
|
||||
register_loader_type(object, NullProvider)
|
||||
|
||||
|
||||
def _parents(path):
|
||||
"""
|
||||
yield all parents of path including path
|
||||
"""
|
||||
last = None
|
||||
while path != last:
|
||||
yield path
|
||||
last = path
|
||||
path, _ = os.path.split(path)
|
||||
|
||||
|
||||
class EggProvider(NullProvider):
|
||||
"""Provider based on a virtual filesystem"""
|
||||
|
||||
@@ -1583,18 +1595,16 @@ class EggProvider(NullProvider):
|
||||
self._setup_prefix()
|
||||
|
||||
def _setup_prefix(self):
|
||||
# we assume here that our metadata may be nested inside a "basket"
|
||||
# of multiple eggs; that's why we use module_path instead of .archive
|
||||
path = self.module_path
|
||||
old = None
|
||||
while path != old:
|
||||
if _is_egg_path(path):
|
||||
self.egg_name = os.path.basename(path)
|
||||
self.egg_info = os.path.join(path, 'EGG-INFO')
|
||||
self.egg_root = path
|
||||
break
|
||||
old = path
|
||||
path, base = os.path.split(path)
|
||||
# Assume that metadata may be nested inside a "basket"
|
||||
# of multiple eggs and use module_path instead of .archive.
|
||||
eggs = filter(_is_egg_path, _parents(self.module_path))
|
||||
egg = next(eggs, None)
|
||||
egg and self._set_egg(egg)
|
||||
|
||||
def _set_egg(self, path):
|
||||
self.egg_name = os.path.basename(path)
|
||||
self.egg_info = os.path.join(path, 'EGG-INFO')
|
||||
self.egg_root = path
|
||||
|
||||
|
||||
class DefaultProvider(EggProvider):
|
||||
@@ -2067,11 +2077,14 @@ def find_on_path(importer, path_item, only=False):
|
||||
|
||||
|
||||
def dist_factory(path_item, entry, only):
|
||||
"""
|
||||
Return a dist_factory for a path_item and entry
|
||||
"""
|
||||
"""Return a dist_factory for the given entry."""
|
||||
lower = entry.lower()
|
||||
is_meta = any(map(lower.endswith, ('.egg-info', '.dist-info')))
|
||||
is_egg_info = lower.endswith('.egg-info')
|
||||
is_dist_info = (
|
||||
lower.endswith('.dist-info') and
|
||||
os.path.isdir(os.path.join(path_item, entry))
|
||||
)
|
||||
is_meta = is_egg_info or is_dist_info
|
||||
return (
|
||||
distributions_from_metadata
|
||||
if is_meta else
|
||||
@@ -2195,10 +2208,14 @@ def _handle_ns(packageName, path_item):
|
||||
if importer is None:
|
||||
return None
|
||||
|
||||
# capture warnings due to #1111
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
loader = importer.find_module(packageName)
|
||||
# use find_spec (PEP 451) and fall-back to find_module (PEP 302)
|
||||
try:
|
||||
loader = importer.find_spec(packageName).loader
|
||||
except AttributeError:
|
||||
# capture warnings due to #1111
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
loader = importer.find_module(packageName)
|
||||
|
||||
if loader is None:
|
||||
return None
|
||||
@@ -2270,8 +2287,8 @@ def declare_namespace(packageName):
|
||||
__import__(parent)
|
||||
try:
|
||||
path = sys.modules[parent].__path__
|
||||
except AttributeError:
|
||||
raise TypeError("Not a package:", parent)
|
||||
except AttributeError as e:
|
||||
raise TypeError("Not a package:", parent) from e
|
||||
|
||||
# Track what packages are namespaces, so when new path items are added,
|
||||
# they can be updated
|
||||
@@ -2328,7 +2345,8 @@ register_namespace_handler(object, null_ns_handler)
|
||||
|
||||
def normalize_path(filename):
|
||||
"""Normalize a file/dir name for comparison purposes"""
|
||||
return os.path.normcase(os.path.realpath(os.path.normpath(_cygwin_patch(filename))))
|
||||
return os.path.normcase(os.path.realpath(os.path.normpath(
|
||||
_cygwin_patch(filename))))
|
||||
|
||||
|
||||
def _cygwin_patch(filename): # pragma: nocover
|
||||
@@ -2450,7 +2468,7 @@ class EntryPoint:
|
||||
try:
|
||||
return functools.reduce(getattr, self.attrs, module)
|
||||
except AttributeError as exc:
|
||||
raise ImportError(str(exc))
|
||||
raise ImportError(str(exc)) from exc
|
||||
|
||||
def require(self, env=None, installer=None):
|
||||
if self.extras and not self.dist:
|
||||
@@ -2536,15 +2554,6 @@ class EntryPoint:
|
||||
return maps
|
||||
|
||||
|
||||
def _remove_md5_fragment(location):
|
||||
if not location:
|
||||
return ''
|
||||
parsed = urllib.parse.urlparse(location)
|
||||
if parsed[-1].startswith('md5='):
|
||||
return urllib.parse.urlunparse(parsed[:-1] + ('',))
|
||||
return location
|
||||
|
||||
|
||||
def _version_from_file(lines):
|
||||
"""
|
||||
Given an iterable of lines from a Metadata file, return
|
||||
@@ -2601,7 +2610,7 @@ class Distribution:
|
||||
self.parsed_version,
|
||||
self.precedence,
|
||||
self.key,
|
||||
_remove_md5_fragment(self.location),
|
||||
self.location,
|
||||
self.py_version or '',
|
||||
self.platform or '',
|
||||
)
|
||||
@@ -2679,14 +2688,14 @@ class Distribution:
|
||||
def version(self):
|
||||
try:
|
||||
return self._version
|
||||
except AttributeError:
|
||||
except AttributeError as e:
|
||||
version = self._get_version()
|
||||
if version is None:
|
||||
path = self._get_metadata_path_for_display(self.PKG_INFO)
|
||||
msg = (
|
||||
"Missing 'Version:' header and/or {} file at path: {}"
|
||||
).format(self.PKG_INFO, path)
|
||||
raise ValueError(msg, self)
|
||||
raise ValueError(msg, self) from e
|
||||
|
||||
return version
|
||||
|
||||
@@ -2739,10 +2748,10 @@ class Distribution:
|
||||
for ext in extras:
|
||||
try:
|
||||
deps.extend(dm[safe_extra(ext)])
|
||||
except KeyError:
|
||||
except KeyError as e:
|
||||
raise UnknownExtra(
|
||||
"%s has no such extra feature %r" % (self, ext)
|
||||
)
|
||||
) from e
|
||||
return deps
|
||||
|
||||
def _get_metadata_path_for_display(self, name):
|
||||
@@ -3067,11 +3076,6 @@ def issue_warning(*args, **kw):
|
||||
warnings.warn(stacklevel=level + 1, *args, **kw)
|
||||
|
||||
|
||||
class RequirementParseError(ValueError):
|
||||
def __str__(self):
|
||||
return ' '.join(self.args)
|
||||
|
||||
|
||||
def parse_requirements(strs):
|
||||
"""Yield ``Requirement`` objects for each specification in `strs`
|
||||
|
||||
@@ -3094,13 +3098,14 @@ def parse_requirements(strs):
|
||||
yield Requirement(line)
|
||||
|
||||
|
||||
class RequirementParseError(packaging.requirements.InvalidRequirement):
|
||||
"Compatibility wrapper for InvalidRequirement"
|
||||
|
||||
|
||||
class Requirement(packaging.requirements.Requirement):
|
||||
def __init__(self, requirement_string):
|
||||
"""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))
|
||||
super(Requirement, self).__init__(requirement_string)
|
||||
self.unsafe_name = self.name
|
||||
project_name = safe_name(self.name)
|
||||
self.project_name, self.key = project_name, project_name.lower()
|
||||
@@ -3109,6 +3114,7 @@ class Requirement(packaging.requirements.Requirement):
|
||||
self.extras = tuple(map(safe_extra, self.extras))
|
||||
self.hashCmp = (
|
||||
self.key,
|
||||
self.url,
|
||||
self.specifier,
|
||||
frozenset(self.extras),
|
||||
str(self.marker) if self.marker else None,
|
||||
@@ -3169,7 +3175,7 @@ def _find_adapter(registry, ob):
|
||||
def ensure_directory(path):
|
||||
"""Ensure that the parent directory of `path` exists"""
|
||||
dirname = os.path.dirname(path)
|
||||
py31compat.makedirs(dirname, exist_ok=True)
|
||||
os.makedirs(dirname, exist_ok=True)
|
||||
|
||||
|
||||
def _bypass_ensure_directory(path):
|
||||
@@ -3286,6 +3292,7 @@ def _initialize_master_working_set():
|
||||
list(map(working_set.add_entry, sys.path))
|
||||
globals().update(locals())
|
||||
|
||||
|
||||
class PkgResourcesDeprecationWarning(Warning):
|
||||
"""
|
||||
Base class for warning about deprecations in ``pkg_resources``
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,18 +4,24 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__all__ = [
|
||||
"__title__", "__summary__", "__uri__", "__version__", "__author__",
|
||||
"__email__", "__license__", "__copyright__",
|
||||
"__title__",
|
||||
"__summary__",
|
||||
"__uri__",
|
||||
"__version__",
|
||||
"__author__",
|
||||
"__email__",
|
||||
"__license__",
|
||||
"__copyright__",
|
||||
]
|
||||
|
||||
__title__ = "packaging"
|
||||
__summary__ = "Core utilities for Python packages"
|
||||
__uri__ = "https://github.com/pypa/packaging"
|
||||
|
||||
__version__ = "16.8"
|
||||
__version__ = "19.2"
|
||||
|
||||
__author__ = "Donald Stufft and individual contributors"
|
||||
__email__ = "donald@stufft.io"
|
||||
|
||||
__license__ = "BSD or Apache License, Version 2.0"
|
||||
__copyright__ = "Copyright 2014-2016 %s" % __author__
|
||||
__copyright__ = "Copyright 2014-2019 %s" % __author__
|
||||
|
||||
@@ -4,11 +4,23 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from .__about__ import (
|
||||
__author__, __copyright__, __email__, __license__, __summary__, __title__,
|
||||
__uri__, __version__
|
||||
__author__,
|
||||
__copyright__,
|
||||
__email__,
|
||||
__license__,
|
||||
__summary__,
|
||||
__title__,
|
||||
__uri__,
|
||||
__version__,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"__title__", "__summary__", "__uri__", "__version__", "__author__",
|
||||
"__email__", "__license__", "__copyright__",
|
||||
"__title__",
|
||||
"__summary__",
|
||||
"__uri__",
|
||||
"__version__",
|
||||
"__author__",
|
||||
"__email__",
|
||||
"__license__",
|
||||
"__copyright__",
|
||||
]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,9 +12,9 @@ PY3 = sys.version_info[0] == 3
|
||||
# flake8: noqa
|
||||
|
||||
if PY3:
|
||||
string_types = str,
|
||||
string_types = (str,)
|
||||
else:
|
||||
string_types = basestring,
|
||||
string_types = (basestring,)
|
||||
|
||||
|
||||
def with_metaclass(meta, *bases):
|
||||
@@ -27,4 +27,5 @@ def with_metaclass(meta, *bases):
|
||||
class metaclass(meta):
|
||||
def __new__(cls, name, this_bases, d):
|
||||
return meta(name, bases, d)
|
||||
return type.__new__(metaclass, 'temporary_class', (), {})
|
||||
|
||||
return type.__new__(metaclass, "temporary_class", (), {})
|
||||
|
||||
@@ -5,7 +5,6 @@ from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
||||
class Infinity(object):
|
||||
|
||||
def __repr__(self):
|
||||
return "Infinity"
|
||||
|
||||
@@ -33,11 +32,11 @@ class Infinity(object):
|
||||
def __neg__(self):
|
||||
return NegativeInfinity
|
||||
|
||||
|
||||
Infinity = Infinity()
|
||||
|
||||
|
||||
class NegativeInfinity(object):
|
||||
|
||||
def __repr__(self):
|
||||
return "-Infinity"
|
||||
|
||||
@@ -65,4 +64,5 @@ class NegativeInfinity(object):
|
||||
def __neg__(self):
|
||||
return Infinity
|
||||
|
||||
|
||||
NegativeInfinity = NegativeInfinity()
|
||||
|
||||
@@ -17,8 +17,11 @@ from .specifiers import Specifier, InvalidSpecifier
|
||||
|
||||
|
||||
__all__ = [
|
||||
"InvalidMarker", "UndefinedComparison", "UndefinedEnvironmentName",
|
||||
"Marker", "default_environment",
|
||||
"InvalidMarker",
|
||||
"UndefinedComparison",
|
||||
"UndefinedEnvironmentName",
|
||||
"Marker",
|
||||
"default_environment",
|
||||
]
|
||||
|
||||
|
||||
@@ -42,7 +45,6 @@ class UndefinedEnvironmentName(ValueError):
|
||||
|
||||
|
||||
class Node(object):
|
||||
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
@@ -57,62 +59,52 @@ class Node(object):
|
||||
|
||||
|
||||
class Variable(Node):
|
||||
|
||||
def serialize(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
class Value(Node):
|
||||
|
||||
def serialize(self):
|
||||
return '"{0}"'.format(self)
|
||||
|
||||
|
||||
class Op(Node):
|
||||
|
||||
def serialize(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
VARIABLE = (
|
||||
L("implementation_version") |
|
||||
L("platform_python_implementation") |
|
||||
L("implementation_name") |
|
||||
L("python_full_version") |
|
||||
L("platform_release") |
|
||||
L("platform_version") |
|
||||
L("platform_machine") |
|
||||
L("platform_system") |
|
||||
L("python_version") |
|
||||
L("sys_platform") |
|
||||
L("os_name") |
|
||||
L("os.name") | # PEP-345
|
||||
L("sys.platform") | # PEP-345
|
||||
L("platform.version") | # PEP-345
|
||||
L("platform.machine") | # PEP-345
|
||||
L("platform.python_implementation") | # PEP-345
|
||||
L("python_implementation") | # undocumented setuptools legacy
|
||||
L("extra")
|
||||
L("implementation_version")
|
||||
| L("platform_python_implementation")
|
||||
| L("implementation_name")
|
||||
| L("python_full_version")
|
||||
| L("platform_release")
|
||||
| L("platform_version")
|
||||
| L("platform_machine")
|
||||
| L("platform_system")
|
||||
| L("python_version")
|
||||
| L("sys_platform")
|
||||
| L("os_name")
|
||||
| L("os.name")
|
||||
| L("sys.platform") # PEP-345
|
||||
| L("platform.version") # PEP-345
|
||||
| L("platform.machine") # PEP-345
|
||||
| L("platform.python_implementation") # PEP-345
|
||||
| L("python_implementation") # PEP-345
|
||||
| L("extra") # undocumented setuptools legacy
|
||||
)
|
||||
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'
|
||||
"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("===") |
|
||||
L("==") |
|
||||
L(">=") |
|
||||
L("<=") |
|
||||
L("!=") |
|
||||
L("~=") |
|
||||
L(">") |
|
||||
L("<")
|
||||
L("===") | L("==") | L(">=") | L("<=") | L("!=") | L("~=") | L(">") | L("<")
|
||||
)
|
||||
|
||||
MARKER_OP = VERSION_CMP | L("not in") | L("in")
|
||||
@@ -152,8 +144,11 @@ def _format_marker(marker, first=True):
|
||||
# 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
|
||||
# outside.
|
||||
if (isinstance(marker, list) and len(marker) == 1 and
|
||||
isinstance(marker[0], (list, tuple))):
|
||||
if (
|
||||
isinstance(marker, list)
|
||||
and len(marker) == 1
|
||||
and isinstance(marker[0], (list, tuple))
|
||||
):
|
||||
return _format_marker(marker[0])
|
||||
|
||||
if isinstance(marker, list):
|
||||
@@ -239,20 +234,20 @@ def _evaluate_markers(markers, environment):
|
||||
|
||||
|
||||
def format_full_version(info):
|
||||
version = '{0.major}.{0.minor}.{0.micro}'.format(info)
|
||||
version = "{0.major}.{0.minor}.{0.micro}".format(info)
|
||||
kind = info.releaselevel
|
||||
if kind != 'final':
|
||||
if kind != "final":
|
||||
version += kind[0] + str(info.serial)
|
||||
return version
|
||||
|
||||
|
||||
def default_environment():
|
||||
if hasattr(sys, 'implementation'):
|
||||
if hasattr(sys, "implementation"):
|
||||
iver = format_full_version(sys.implementation.version)
|
||||
implementation_name = sys.implementation.name
|
||||
else:
|
||||
iver = '0'
|
||||
implementation_name = ''
|
||||
iver = "0"
|
||||
implementation_name = ""
|
||||
|
||||
return {
|
||||
"implementation_name": implementation_name,
|
||||
@@ -264,19 +259,19 @@ def default_environment():
|
||||
"platform_version": platform.version(),
|
||||
"python_full_version": platform.python_version(),
|
||||
"platform_python_implementation": platform.python_implementation(),
|
||||
"python_version": platform.python_version()[:3],
|
||||
"python_version": ".".join(platform.python_version_tuple()[:2]),
|
||||
"sys_platform": sys.platform,
|
||||
}
|
||||
|
||||
|
||||
class Marker(object):
|
||||
|
||||
def __init__(self, marker):
|
||||
try:
|
||||
self._markers = _coerce_parse_result(MARKER.parseString(marker))
|
||||
except ParseException as e:
|
||||
err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
|
||||
marker, marker[e.loc:e.loc + 8])
|
||||
marker, marker[e.loc : e.loc + 8]
|
||||
)
|
||||
raise InvalidMarker(err_str)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -38,8 +38,8 @@ IDENTIFIER = Combine(ALPHANUM + ZeroOrMore(IDENTIFIER_END))
|
||||
NAME = IDENTIFIER("name")
|
||||
EXTRA = IDENTIFIER
|
||||
|
||||
URI = Regex(r'[^ ]+')("url")
|
||||
URL = (AT + URI)
|
||||
URI = Regex(r"[^ ]+")("url")
|
||||
URL = AT + URI
|
||||
|
||||
EXTRAS_LIST = EXTRA + ZeroOrMore(COMMA + EXTRA)
|
||||
EXTRAS = (LBRACKET + Optional(EXTRAS_LIST) + RBRACKET)("extras")
|
||||
@@ -48,28 +48,31 @@ VERSION_PEP440 = Regex(Specifier._regex_str, re.VERBOSE | re.IGNORECASE)
|
||||
VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
VERSION_ONE = VERSION_PEP440 ^ VERSION_LEGACY
|
||||
VERSION_MANY = Combine(VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE),
|
||||
joinString=",", adjacent=False)("_raw_spec")
|
||||
VERSION_MANY = Combine(
|
||||
VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE), joinString=",", adjacent=False
|
||||
)("_raw_spec")
|
||||
_VERSION_SPEC = Optional(((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY))
|
||||
_VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or '')
|
||||
_VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or "")
|
||||
|
||||
VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier")
|
||||
VERSION_SPEC.setParseAction(lambda s, l, t: t[1])
|
||||
|
||||
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
|
||||
MARKER_EXPR.setParseAction(
|
||||
lambda s, l, t: Marker(s[t._original_start:t._original_end])
|
||||
lambda s, l, t: Marker(s[t._original_start : t._original_end])
|
||||
)
|
||||
MARKER_SEPERATOR = SEMICOLON
|
||||
MARKER = MARKER_SEPERATOR + MARKER_EXPR
|
||||
MARKER_SEPARATOR = SEMICOLON
|
||||
MARKER = MARKER_SEPARATOR + MARKER_EXPR
|
||||
|
||||
VERSION_AND_MARKER = VERSION_SPEC + Optional(MARKER)
|
||||
URL_AND_MARKER = URL + Optional(MARKER)
|
||||
|
||||
NAMED_REQUIREMENT = \
|
||||
NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER)
|
||||
NAMED_REQUIREMENT = NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER)
|
||||
|
||||
REQUIREMENT = stringStart + NAMED_REQUIREMENT + stringEnd
|
||||
# pkg_resources.extern.pyparsing isn't thread safe during initialization, so we do it eagerly, see
|
||||
# issue #104
|
||||
REQUIREMENT.parseString("x[]")
|
||||
|
||||
|
||||
class Requirement(object):
|
||||
@@ -90,15 +93,21 @@ class Requirement(object):
|
||||
req = REQUIREMENT.parseString(requirement_string)
|
||||
except ParseException as e:
|
||||
raise InvalidRequirement(
|
||||
"Invalid requirement, parse error at \"{0!r}\"".format(
|
||||
requirement_string[e.loc:e.loc + 8]))
|
||||
'Parse error at "{0!r}": {1}'.format(
|
||||
requirement_string[e.loc : e.loc + 8], e.msg
|
||||
)
|
||||
)
|
||||
|
||||
self.name = req.name
|
||||
if req.url:
|
||||
parsed_url = urlparse.urlparse(req.url)
|
||||
if not (parsed_url.scheme and parsed_url.netloc) or (
|
||||
not parsed_url.scheme and not parsed_url.netloc):
|
||||
raise InvalidRequirement("Invalid URL given")
|
||||
if parsed_url.scheme == "file":
|
||||
if urlparse.urlunparse(parsed_url) != req.url:
|
||||
raise InvalidRequirement("Invalid URL given")
|
||||
elif not (parsed_url.scheme and parsed_url.netloc) or (
|
||||
not parsed_url.scheme and not parsed_url.netloc
|
||||
):
|
||||
raise InvalidRequirement("Invalid URL: {0}".format(req.url))
|
||||
self.url = req.url
|
||||
else:
|
||||
self.url = None
|
||||
@@ -117,6 +126,8 @@ class Requirement(object):
|
||||
|
||||
if self.url:
|
||||
parts.append("@ {0}".format(self.url))
|
||||
if self.marker:
|
||||
parts.append(" ")
|
||||
|
||||
if self.marker:
|
||||
parts.append("; {0}".format(self.marker))
|
||||
|
||||
@@ -19,7 +19,6 @@ class InvalidSpecifier(ValueError):
|
||||
|
||||
|
||||
class BaseSpecifier(with_metaclass(abc.ABCMeta, object)):
|
||||
|
||||
@abc.abstractmethod
|
||||
def __str__(self):
|
||||
"""
|
||||
@@ -84,10 +83,7 @@ class _IndividualSpecifier(BaseSpecifier):
|
||||
if not match:
|
||||
raise InvalidSpecifier("Invalid specifier: '{0}'".format(spec))
|
||||
|
||||
self._spec = (
|
||||
match.group("operator").strip(),
|
||||
match.group("version").strip(),
|
||||
)
|
||||
self._spec = (match.group("operator").strip(), match.group("version").strip())
|
||||
|
||||
# Store whether or not this Specifier should accept prereleases
|
||||
self._prereleases = prereleases
|
||||
@@ -99,11 +95,7 @@ class _IndividualSpecifier(BaseSpecifier):
|
||||
else ""
|
||||
)
|
||||
|
||||
return "<{0}({1!r}{2})>".format(
|
||||
self.__class__.__name__,
|
||||
str(self),
|
||||
pre,
|
||||
)
|
||||
return "<{0}({1!r}{2})>".format(self.__class__.__name__, str(self), pre)
|
||||
|
||||
def __str__(self):
|
||||
return "{0}{1}".format(*self._spec)
|
||||
@@ -194,11 +186,12 @@ 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.
|
||||
# accepting prereleases from the beginning.
|
||||
else:
|
||||
yielded = True
|
||||
yield version
|
||||
@@ -213,8 +206,7 @@ class _IndividualSpecifier(BaseSpecifier):
|
||||
|
||||
class LegacySpecifier(_IndividualSpecifier):
|
||||
|
||||
_regex_str = (
|
||||
r"""
|
||||
_regex_str = r"""
|
||||
(?P<operator>(==|!=|<=|>=|<|>))
|
||||
\s*
|
||||
(?P<version>
|
||||
@@ -225,10 +217,8 @@ class LegacySpecifier(_IndividualSpecifier):
|
||||
# them, and a comma since it's a version separator.
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
_regex = re.compile(
|
||||
r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
_regex = re.compile(r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
_operators = {
|
||||
"==": "equal",
|
||||
@@ -269,13 +259,13 @@ def _require_version_compare(fn):
|
||||
if not isinstance(prospective, Version):
|
||||
return False
|
||||
return fn(self, prospective, spec)
|
||||
|
||||
return wrapped
|
||||
|
||||
|
||||
class Specifier(_IndividualSpecifier):
|
||||
|
||||
_regex_str = (
|
||||
r"""
|
||||
_regex_str = r"""
|
||||
(?P<operator>(~=|==|!=|<=|>=|<|>|===))
|
||||
(?P<version>
|
||||
(?:
|
||||
@@ -367,10 +357,8 @@ class Specifier(_IndividualSpecifier):
|
||||
)
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
_regex = re.compile(
|
||||
r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
_regex = re.compile(r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
_operators = {
|
||||
"~=": "compatible",
|
||||
@@ -397,8 +385,7 @@ 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,8 +394,9 @@ 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):
|
||||
@@ -428,7 +416,7 @@ class Specifier(_IndividualSpecifier):
|
||||
# Shorten the prospective version to be the same length as the spec
|
||||
# so that we can determine if the specifier is a prefix of the
|
||||
# prospective version or not.
|
||||
prospective = prospective[:len(spec)]
|
||||
prospective = prospective[: len(spec)]
|
||||
|
||||
# Pad out our two sides with zeros so that they both equal the same
|
||||
# length.
|
||||
@@ -503,7 +491,7 @@ class Specifier(_IndividualSpecifier):
|
||||
return False
|
||||
|
||||
# Ensure that we do not allow a local version of the version mentioned
|
||||
# in the specifier, which is techincally greater than, to match.
|
||||
# in the specifier, which is technically greater than, to match.
|
||||
if prospective.local is not None:
|
||||
if Version(prospective.base_version) == Version(spec.base_version):
|
||||
return False
|
||||
@@ -567,27 +555,17 @@ 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[0]) :])
|
||||
right_split.append(right[len(right_split[0]) :])
|
||||
|
||||
# Insert our padding
|
||||
left_split.insert(
|
||||
1,
|
||||
["0"] * max(0, len(right_split[0]) - len(left_split[0])),
|
||||
)
|
||||
right_split.insert(
|
||||
1,
|
||||
["0"] * max(0, len(left_split[0]) - len(right_split[0])),
|
||||
)
|
||||
left_split.insert(1, ["0"] * max(0, len(right_split[0]) - len(left_split[0])))
|
||||
right_split.insert(1, ["0"] * max(0, len(left_split[0]) - len(right_split[0])))
|
||||
|
||||
return (
|
||||
list(itertools.chain(*left_split)),
|
||||
list(itertools.chain(*right_split)),
|
||||
)
|
||||
return (list(itertools.chain(*left_split)), list(itertools.chain(*right_split)))
|
||||
|
||||
|
||||
class SpecifierSet(BaseSpecifier):
|
||||
|
||||
def __init__(self, specifiers="", prereleases=None):
|
||||
# Split on , to break each indidivual specifier into it's own item, and
|
||||
# strip each item to remove leading/trailing whitespace.
|
||||
@@ -721,10 +699,7 @@ class SpecifierSet(BaseSpecifier):
|
||||
# given version is contained within all of them.
|
||||
# Note: This use of all() here means that an empty set of specifiers
|
||||
# will always return True, this is an explicit design decision.
|
||||
return all(
|
||||
s.contains(item, prereleases=prereleases)
|
||||
for s in self._specs
|
||||
)
|
||||
return all(s.contains(item, prereleases=prereleases) for s in self._specs)
|
||||
|
||||
def filter(self, iterable, prereleases=None):
|
||||
# Determine if we're forcing a prerelease or not, if we're not forcing
|
||||
|
||||
@@ -5,6 +5,8 @@ from __future__ import absolute_import, division, print_function
|
||||
|
||||
import re
|
||||
|
||||
from .version import InvalidVersion, Version
|
||||
|
||||
|
||||
_canonicalize_regex = re.compile(r"[-_.]+")
|
||||
|
||||
@@ -12,3 +14,44 @@ _canonicalize_regex = re.compile(r"[-_.]+")
|
||||
def canonicalize_name(name):
|
||||
# This is taken from PEP 503.
|
||||
return _canonicalize_regex.sub("-", name).lower()
|
||||
|
||||
|
||||
def canonicalize_version(version):
|
||||
"""
|
||||
This is very similar to Version.__str__, but has one subtle differences
|
||||
with the way it handles the release segment.
|
||||
"""
|
||||
|
||||
try:
|
||||
version = Version(version)
|
||||
except InvalidVersion:
|
||||
# Legacy versions cannot be normalized
|
||||
return version
|
||||
|
||||
parts = []
|
||||
|
||||
# Epoch
|
||||
if version.epoch != 0:
|
||||
parts.append("{0}!".format(version.epoch))
|
||||
|
||||
# Release segment
|
||||
# NB: This strips trailing '.0's to normalize
|
||||
parts.append(re.sub(r"(\.0)+$", "", ".".join(str(x) for x in version.release)))
|
||||
|
||||
# Pre-release
|
||||
if version.pre is not None:
|
||||
parts.append("".join(str(x) for x in version.pre))
|
||||
|
||||
# Post-release
|
||||
if version.post is not None:
|
||||
parts.append(".post{0}".format(version.post))
|
||||
|
||||
# Development release
|
||||
if version.dev is not None:
|
||||
parts.append(".dev{0}".format(version.dev))
|
||||
|
||||
# Local version segment
|
||||
if version.local is not None:
|
||||
parts.append("+{0}".format(version.local))
|
||||
|
||||
return "".join(parts)
|
||||
|
||||
@@ -10,14 +10,11 @@ import re
|
||||
from ._structures import Infinity
|
||||
|
||||
|
||||
__all__ = [
|
||||
"parse", "Version", "LegacyVersion", "InvalidVersion", "VERSION_PATTERN"
|
||||
]
|
||||
__all__ = ["parse", "Version", "LegacyVersion", "InvalidVersion", "VERSION_PATTERN"]
|
||||
|
||||
|
||||
_Version = collections.namedtuple(
|
||||
"_Version",
|
||||
["epoch", "release", "dev", "pre", "post", "local"],
|
||||
"_Version", ["epoch", "release", "dev", "pre", "post", "local"]
|
||||
)
|
||||
|
||||
|
||||
@@ -40,7 +37,6 @@ class InvalidVersion(ValueError):
|
||||
|
||||
|
||||
class _BaseVersion(object):
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._key)
|
||||
|
||||
@@ -70,7 +66,6 @@ class _BaseVersion(object):
|
||||
|
||||
|
||||
class LegacyVersion(_BaseVersion):
|
||||
|
||||
def __init__(self, version):
|
||||
self._version = str(version)
|
||||
self._key = _legacy_cmpkey(self._version)
|
||||
@@ -89,6 +84,26 @@ class LegacyVersion(_BaseVersion):
|
||||
def base_version(self):
|
||||
return self._version
|
||||
|
||||
@property
|
||||
def epoch(self):
|
||||
return -1
|
||||
|
||||
@property
|
||||
def release(self):
|
||||
return None
|
||||
|
||||
@property
|
||||
def pre(self):
|
||||
return None
|
||||
|
||||
@property
|
||||
def post(self):
|
||||
return None
|
||||
|
||||
@property
|
||||
def dev(self):
|
||||
return None
|
||||
|
||||
@property
|
||||
def local(self):
|
||||
return None
|
||||
@@ -101,13 +116,19 @@ class LegacyVersion(_BaseVersion):
|
||||
def is_postrelease(self):
|
||||
return False
|
||||
|
||||
@property
|
||||
def is_devrelease(self):
|
||||
return False
|
||||
|
||||
_legacy_version_component_re = re.compile(
|
||||
r"(\d+ | [a-z]+ | \.| -)", re.VERBOSE,
|
||||
)
|
||||
|
||||
_legacy_version_component_re = re.compile(r"(\d+ | [a-z]+ | \.| -)", re.VERBOSE)
|
||||
|
||||
_legacy_version_replacement_map = {
|
||||
"pre": "c", "preview": "c", "-": "final-", "rc": "c", "dev": "@",
|
||||
"pre": "c",
|
||||
"preview": "c",
|
||||
"-": "final-",
|
||||
"rc": "c",
|
||||
"dev": "@",
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +175,7 @@ def _legacy_cmpkey(version):
|
||||
|
||||
return epoch, parts
|
||||
|
||||
|
||||
# Deliberately not anchored to the start and end of the string, to make it
|
||||
# easier for 3rd party code to reuse
|
||||
VERSION_PATTERN = r"""
|
||||
@@ -190,10 +212,7 @@ VERSION_PATTERN = r"""
|
||||
|
||||
class Version(_BaseVersion):
|
||||
|
||||
_regex = re.compile(
|
||||
r"^\s*" + VERSION_PATTERN + r"\s*$",
|
||||
re.VERBOSE | re.IGNORECASE,
|
||||
)
|
||||
_regex = re.compile(r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
def __init__(self, version):
|
||||
# Validate the version and parse it into pieces
|
||||
@@ -205,18 +224,11 @@ class Version(_BaseVersion):
|
||||
self._version = _Version(
|
||||
epoch=int(match.group("epoch")) if match.group("epoch") else 0,
|
||||
release=tuple(int(i) for i in match.group("release").split(".")),
|
||||
pre=_parse_letter_version(
|
||||
match.group("pre_l"),
|
||||
match.group("pre_n"),
|
||||
),
|
||||
pre=_parse_letter_version(match.group("pre_l"), match.group("pre_n")),
|
||||
post=_parse_letter_version(
|
||||
match.group("post_l"),
|
||||
match.group("post_n1") or match.group("post_n2"),
|
||||
),
|
||||
dev=_parse_letter_version(
|
||||
match.group("dev_l"),
|
||||
match.group("dev_n"),
|
||||
match.group("post_l"), match.group("post_n1") or match.group("post_n2")
|
||||
),
|
||||
dev=_parse_letter_version(match.group("dev_l"), match.group("dev_n")),
|
||||
local=_parse_local_version(match.group("local")),
|
||||
)
|
||||
|
||||
@@ -237,32 +249,57 @@ class Version(_BaseVersion):
|
||||
parts = []
|
||||
|
||||
# Epoch
|
||||
if self._version.epoch != 0:
|
||||
parts.append("{0}!".format(self._version.epoch))
|
||||
if self.epoch != 0:
|
||||
parts.append("{0}!".format(self.epoch))
|
||||
|
||||
# Release segment
|
||||
parts.append(".".join(str(x) for x in self._version.release))
|
||||
parts.append(".".join(str(x) for x in self.release))
|
||||
|
||||
# Pre-release
|
||||
if self._version.pre is not None:
|
||||
parts.append("".join(str(x) for x in self._version.pre))
|
||||
if self.pre is not None:
|
||||
parts.append("".join(str(x) for x in self.pre))
|
||||
|
||||
# Post-release
|
||||
if self._version.post is not None:
|
||||
parts.append(".post{0}".format(self._version.post[1]))
|
||||
if self.post is not None:
|
||||
parts.append(".post{0}".format(self.post))
|
||||
|
||||
# Development release
|
||||
if self._version.dev is not None:
|
||||
parts.append(".dev{0}".format(self._version.dev[1]))
|
||||
if self.dev is not None:
|
||||
parts.append(".dev{0}".format(self.dev))
|
||||
|
||||
# Local version segment
|
||||
if self._version.local is not None:
|
||||
parts.append(
|
||||
"+{0}".format(".".join(str(x) for x in self._version.local))
|
||||
)
|
||||
if self.local is not None:
|
||||
parts.append("+{0}".format(self.local))
|
||||
|
||||
return "".join(parts)
|
||||
|
||||
@property
|
||||
def epoch(self):
|
||||
return self._version.epoch
|
||||
|
||||
@property
|
||||
def release(self):
|
||||
return self._version.release
|
||||
|
||||
@property
|
||||
def pre(self):
|
||||
return self._version.pre
|
||||
|
||||
@property
|
||||
def post(self):
|
||||
return self._version.post[1] if self._version.post else None
|
||||
|
||||
@property
|
||||
def dev(self):
|
||||
return self._version.dev[1] if self._version.dev else None
|
||||
|
||||
@property
|
||||
def local(self):
|
||||
if self._version.local:
|
||||
return ".".join(str(x) for x in self._version.local)
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def public(self):
|
||||
return str(self).split("+", 1)[0]
|
||||
@@ -272,27 +309,25 @@ class Version(_BaseVersion):
|
||||
parts = []
|
||||
|
||||
# Epoch
|
||||
if self._version.epoch != 0:
|
||||
parts.append("{0}!".format(self._version.epoch))
|
||||
if self.epoch != 0:
|
||||
parts.append("{0}!".format(self.epoch))
|
||||
|
||||
# Release segment
|
||||
parts.append(".".join(str(x) for x in self._version.release))
|
||||
parts.append(".".join(str(x) for x in self.release))
|
||||
|
||||
return "".join(parts)
|
||||
|
||||
@property
|
||||
def local(self):
|
||||
version_string = str(self)
|
||||
if "+" in version_string:
|
||||
return version_string.split("+", 1)[1]
|
||||
|
||||
@property
|
||||
def is_prerelease(self):
|
||||
return bool(self._version.dev or self._version.pre)
|
||||
return self.dev is not None or self.pre is not None
|
||||
|
||||
@property
|
||||
def is_postrelease(self):
|
||||
return bool(self._version.post)
|
||||
return self.post is not None
|
||||
|
||||
@property
|
||||
def is_devrelease(self):
|
||||
return self.dev is not None
|
||||
|
||||
|
||||
def _parse_letter_version(letter, number):
|
||||
@@ -326,7 +361,7 @@ def _parse_letter_version(letter, number):
|
||||
return letter, int(number)
|
||||
|
||||
|
||||
_local_version_seperators = re.compile(r"[\._-]")
|
||||
_local_version_separators = re.compile(r"[\._-]")
|
||||
|
||||
|
||||
def _parse_local_version(local):
|
||||
@@ -336,7 +371,7 @@ def _parse_local_version(local):
|
||||
if local is not None:
|
||||
return tuple(
|
||||
part.lower() if not part.isdigit() else int(part)
|
||||
for part in _local_version_seperators.split(local)
|
||||
for part in _local_version_separators.split(local)
|
||||
)
|
||||
|
||||
|
||||
@@ -347,12 +382,7 @@ def _cmpkey(epoch, release, pre, post, dev, local):
|
||||
# re-reverse it back into the correct order and make it a tuple and use
|
||||
# that for our sorting key.
|
||||
release = tuple(
|
||||
reversed(list(
|
||||
itertools.dropwhile(
|
||||
lambda x: x == 0,
|
||||
reversed(release),
|
||||
)
|
||||
))
|
||||
reversed(list(itertools.dropwhile(lambda x: x == 0, reversed(release))))
|
||||
)
|
||||
|
||||
# We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
|
||||
@@ -385,9 +415,6 @@ def _cmpkey(epoch, release, pre, post, dev, local):
|
||||
# - Numeric segments sort numerically
|
||||
# - Shorter versions sort before longer versions when the prefixes
|
||||
# match exactly
|
||||
local = tuple(
|
||||
(i, "") if isinstance(i, int) else (-Infinity, i)
|
||||
for i in local
|
||||
)
|
||||
local = tuple((i, "") if isinstance(i, int) else (-Infinity, i) for i in local)
|
||||
|
||||
return epoch, release, pre, post, dev, local
|
||||
|
||||
@@ -43,13 +43,6 @@ class VendorImporter:
|
||||
__import__(extant)
|
||||
mod = sys.modules[extant]
|
||||
sys.modules[fullname] = mod
|
||||
# mysterious hack:
|
||||
# Remove the reference to the extant package/module
|
||||
# on later Python versions to cause relative imports
|
||||
# in the vendor package to resolve the same modules
|
||||
# as those going through this importer.
|
||||
if prefix and sys.version_info > (3, 3):
|
||||
del sys.modules[extant]
|
||||
return mod
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
Binary file not shown.
@@ -1,23 +0,0 @@
|
||||
import os
|
||||
import errno
|
||||
import sys
|
||||
|
||||
from .extern import six
|
||||
|
||||
|
||||
def _makedirs_31(path, exist_ok=False):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError as exc:
|
||||
if not exist_ok or exc.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
|
||||
# rely on compatibility behavior until mode considerations
|
||||
# and exists_ok considerations are disentangled.
|
||||
# See https://github.com/pypa/setuptools/pull/1083#issuecomment-315168663
|
||||
needs_makedirs = (
|
||||
six.PY2 or
|
||||
(3, 4) <= sys.version_info < (3, 4, 1)
|
||||
)
|
||||
makedirs = _makedirs_31 if needs_makedirs else os.makedirs
|
||||
Reference in New Issue
Block a user