Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update vendored deps #3280

Merged
merged 4 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .azure-pipelines/jobs/run-manifest-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ steps:
- bash: |
export GIT_SSL_CAINFO=$(python -m certifi)
export LANG=C.UTF-8
python -m pip install check-manifest
check-manifest
python -m pip install --upgrade setuptools twine readme_renderer[md]
python setup.py sdist
twine check dist/*
4 changes: 4 additions & 0 deletions news/3280.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Update vendored dependencies to resolve resolution output parsing and python finding:
- `pythonfinder 1.1.9 -> 1.1.10`
- `requirementslib 1.3.1 -> 1.3.3`
- `vistir 0.2.3 -> 0.2.5`
1 change: 1 addition & 0 deletions pipenv/vendor/pythonfinder/models/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ def get_py_version(self):
if self.is_dir:
return None
if self.is_python:
py_version = None
try:
py_version = PythonVersion.from_path(path=self, name=self.name)
except (InvalidPythonVersion, ValueError):
Expand Down
20 changes: 11 additions & 9 deletions pipenv/vendor/pythonfinder/models/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from vistir.compat import Path

from ..environment import SYSTEM_ARCH, PYENV_ROOT, ASDF_DATA_DIR
from ..exceptions import InvalidPythonVersion
from .mixins import BaseFinder, BasePath
from ..utils import (
_filter_none,
Expand Down Expand Up @@ -109,7 +110,7 @@ def get_versions(self):
version = None
try:
version = PythonVersion.parse(p.name)
except ValueError:
except (ValueError, InvalidPythonVersion):
entry = next(iter(version_path.find_all_python_versions()), None)
if not entry:
if self.ignore_unsupported:
Expand Down Expand Up @@ -246,7 +247,7 @@ class PythonVersion(object):
is_postrelease = attr.ib(default=False)
is_devrelease = attr.ib(default=False)
is_debug = attr.ib(default=False)
version = attr.ib(default=None, validator=optional_instance_of(Version))
version = attr.ib(default=None)
architecture = attr.ib(default=None)
comes_from = attr.ib(default=None)
executable = attr.ib(default=None)
Expand Down Expand Up @@ -368,7 +369,7 @@ def get_architecture(self):
return self.architecture

@classmethod
def from_path(cls, path, name=None):
def from_path(cls, path, name=None, ignore_unsupported=True):
"""Parses a python version from a system path.

Raises:
Expand All @@ -377,23 +378,24 @@ def from_path(cls, path, name=None):
:param path: A string or :class:`~pythonfinder.models.path.PathEntry`
:type path: str or :class:`~pythonfinder.models.path.PathEntry` instance
:param str name: Name of the python distribution in question
:param bool ignore_unsupported: Whether to ignore or error on unsupported paths.
:return: An instance of a PythonVersion.
:rtype: :class:`~pythonfinder.models.python.PythonVersion`
"""

from .path import PathEntry
from ..environment import IGNORE_UNSUPPORTED

if not isinstance(path, PathEntry):
path = PathEntry.create(path, is_root=False, only_python=True, name=name)
if not path.is_python and not IGNORE_UNSUPPORTED:
raise ValueError("Not a valid python path: %s" % path.path)
return
from ..environment import IGNORE_UNSUPPORTED
ignore_unsupported = ignore_unsupported or IGNORE_UNSUPPORTED
if not path.is_python:
if not (ignore_unsupported or IGNORE_UNSUPPORTED):
raise ValueError("Not a valid python path: %s" % path.path)
py_version = get_python_version(path.path.absolute().as_posix())
instance_dict = cls.parse(py_version.strip())
if not isinstance(instance_dict.get("version"), Version) and not IGNORE_UNSUPPORTED:
if not isinstance(instance_dict.get("version"), Version) and not ignore_unsupported:
raise ValueError("Not a valid python path: %s" % path.path)
return
if not name:
name = path.name
instance_dict.update(
Expand Down
22 changes: 16 additions & 6 deletions pipenv/vendor/pythonfinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from attr.validators import _OptionalValidator


version_re = re.compile(r"(?P<major>\d+)\.(?P<minor>\d+)\.?(?P<patch>(?<=\.)[0-9]+)?\.?"
version_re = re.compile(r"(?P<major>\d+)(?:\.(?P<minor>\d+))?(?:\.(?P<patch>(?<=\.)[0-9]+))?\.?"
r"(?:(?P<prerel>[abc]|rc|dev)(?:(?P<prerelversion>\d+(?:\.\d+)*))?)"
r"?(?P<postdev>(\.post(?P<post>\d+))?(\.dev(?P<dev>\d+))?)?")

Expand Down Expand Up @@ -81,10 +81,10 @@ def parse_python_version(version_str):
if version_str.endswith("-debug"):
is_debug = True
version_str, _, _ = version_str.rpartition("-")
m = version_re.match(version_str)
if not m:
match = version_re.match(version_str)
if not match:
raise InvalidPythonVersion("%s is not a python version" % version_str)
version_dict = m.groupdict() # type: Dict[str, str]
version_dict = match.groupdict() # type: Dict[str, str]
major = int(version_dict.get("major", 0)) if version_dict.get("major") else None
minor = int(version_dict.get("minor", 0)) if version_dict.get("minor") else None
patch = int(version_dict.get("patch", 0)) if version_dict.get("patch") else None
Expand All @@ -97,8 +97,18 @@ def parse_python_version(version_str):
try:
version = parse_version(version_str)
except TypeError:
version_parts = [str(v) for v in [major, minor, patch] if v is not None]
version = parse_version(".".join(version_parts))
version = None
if isinstance(version, LegacyVersion) or version is None:
v_dict = version_dict.copy()
pre = ""
if v_dict.get("prerel") and v_dict.get("prerelversion"):
pre = v_dict.pop("prerel")
pre = "{0}{1}".format(pre, v_dict.pop("prerelversion"))
v_dict["pre"] = pre
keys = ["major", "minor", "patch", "pre", "postdev", "post", "dev"]
values = [v_dict.get(val) for val in keys]
version_str = ".".join([str(v) for v in values if v])
version = parse_version(version_str)
return {
"major": major,
"minor": minor,
Expand Down
6 changes: 3 additions & 3 deletions pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pipdeptree==0.13.0
pipreqs==0.4.9
docopt==0.6.2
yarg==0.1.9
pythonfinder==1.1.9.post1
pythonfinder==1.1.10
requests==2.20.1
chardet==3.0.4
idna==2.7
urllib3==1.24
certifi==2018.10.15
requirementslib==1.3.1.post1
requirementslib==1.3.3
attrs==18.2.0
distlib==0.2.8
packaging==18.0
Expand All @@ -40,7 +40,7 @@ semver==2.8.1
shutilwhich==1.1.0
toml==0.10.0
cached-property==1.4.3
vistir==0.2.4
vistir==0.2.5
pip-shims==0.3.2
ptyprocess==0.6.0
enum34==1.1.6
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vistir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .spin import VistirSpinner, create_spinner


__version__ = '0.2.4'
__version__ = '0.2.5'


__all__ = [
Expand Down
3 changes: 3 additions & 0 deletions pipenv/vendor/vistir/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class IsADirectoryError(OSError):
else:
from builtins import ResourceWarning, FileNotFoundError, PermissionError, IsADirectoryError

six.add_move(six.MovedAttribute("Iterable", "collections", "collections.abc"))
from six.moves import Iterable


if not sys.warnoptions:
warnings.simplefilter("default", ResourceWarning)
Expand Down
22 changes: 12 additions & 10 deletions pipenv/vendor/vistir/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

from collections import OrderedDict
from functools import partial
from itertools import islice
from itertools import islice, tee

import six

from .cmdparse import Script
from .compat import Path, fs_str, partialmethod, to_native_string
from .compat import Path, fs_str, partialmethod, to_native_string, Iterable
from .contextmanagers import spinner as spinner

if os.name != "nt":
Expand Down Expand Up @@ -78,15 +78,17 @@ def unnest(elem):
[1234, 3456, 4398345, 234234, 2396, 23895750, 9283798, 29384, 289375983275, 293759, 2347, 2098, 7987, 27599]
"""

if _is_iterable(elem):
for item in elem:
if _is_iterable(item):
for sub_item in unnest(item):
yield sub_item
else:
yield item
if isinstance(elem, Iterable) and not isinstance(elem, six.string_types):
elem, target = tee(elem, 2)
else:
raise ValueError("Expecting an iterable, got %r" % elem)
target = elem
for el in target:
if isinstance(el, Iterable) and not isinstance(el, six.string_types):
el, el_copy = tee(el, 2)
for sub in unnest(el_copy):
yield sub
else:
yield el


def _is_iterable(elem):
Expand Down
29 changes: 29 additions & 0 deletions pipenv/vendor/vistir/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"check_for_unc_path",
"get_converted_relative_path",
"handle_remove_readonly",
"normalize_path",
"is_in_path",
"is_file_url",
"is_readonly_path",
"is_valid_url",
Expand Down Expand Up @@ -80,6 +82,33 @@ def abspathu(path):
return os.path.normpath(path)


def normalize_path(path):
"""
Return a case-normalized absolute variable-expanded path.

:param str path: The non-normalized path
:return: A normalized, expanded, case-normalized path
:rtype: str
"""

return os.path.normpath(os.path.normcase(
os.path.abspath(os.path.expandvars(os.path.expanduser(str(path))))
))


def is_in_path(path, parent):
"""
Determine if the provided full path is in the given parent root.

:param str path: The full path to check the location of.
:param str parent: The parent path to check for membership in
:return: Whether the full path is a member of the provided parent.
:rtype: bool
"""

return normalize_path(str(path)).startswith(normalize_path(str(parent)))


def normalize_drive(path):
"""Normalize drive in path so they stay consistent.

Expand Down
6 changes: 4 additions & 2 deletions pipenv/vendor/vistir/spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import six

from .compat import to_native_string
from .termcolors import COLOR_MAP, COLORS, colored
from .termcolors import COLOR_MAP, COLORS, colored, DISABLE_COLORS
from io import StringIO

try:
Expand All @@ -34,7 +34,9 @@

class DummySpinner(object):
def __init__(self, text="", **kwargs):
colorama.init()
super(DummySpinner, self).__init__()
if DISABLE_COLORS:
colorama.init()
from .misc import decode_for_output
self.text = to_native_string(decode_for_output(text)) if text else ""
self.stdout = kwargs.get("stdout", sys.stdout)
Expand Down
5 changes: 5 additions & 0 deletions pipenv/vendor/vistir/termcolors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from .compat import to_native_string


DISABLE_COLORS = os.getenv("CI", False) or os.getenv("ANSI_COLORS_DISABLED",
os.getenv("VISTIR_DISABLE_COLORS", False)
)


ATTRIBUTES = dict(
list(zip([
'bold',
Expand Down