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

Update requirementslib #2617

Merged
merged 1 commit into from
Jul 21, 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
1 change: 1 addition & 0 deletions news/2617.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update requirementslib to fix a bug which could raise an ``UnboundLocalError`` when parsing malformed VCS URIs.
1 change: 1 addition & 0 deletions news/2617.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update requirementslib to fix a bug which could raise an ``UnboundLocalError`` when parsing malformed VCS URIs.
2 changes: 1 addition & 1 deletion pipenv/vendor/requirementslib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding=utf-8 -*-
__version__ = "1.0.10"
__version__ = "1.0.11"


from .exceptions import RequirementError
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/requirementslib/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def get_link_from_line(cls, line):
# This is an URI. We'll need to perform some elaborated parsing.

parsed_url = urllib_parse.urlsplit(fixed_line)
original_url = parsed_url._replace()
if added_ssh_scheme and ':' in parsed_url.netloc:
original_netloc, original_path_start = parsed_url.netloc.rsplit(':', 1)
uri_path = '/{0}{1}'.format(original_path_start, parsed_url.path)
original_url = parsed_url
parsed_url = original_url._replace(netloc=original_netloc, path=uri_path)

# Split the VCS part out if needed.
Expand Down
32 changes: 29 additions & 3 deletions pipenv/vendor/requirementslib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ def is_vcs(pipfile_entry):
return False


def check_for_unc_path(path):
""" Checks to see if a pathlib `Path` object is a unc path or not"""
if (
os.name == "nt"
and len(path.drive) > 2
and not path.drive[0].isalpha()
and path.drive[1] != ":"
):
return True
else:
return False


def get_converted_relative_path(path, relative_to=os.curdir):
"""Convert `path` to be relative.

Expand All @@ -69,13 +82,26 @@ def get_converted_relative_path(path, relative_to=os.curdir):
This performs additional conversion to ensure the result is of POSIX form,
and starts with `./`, or is precisely `.`.
"""
start = Path(relative_to)

start_path = Path(relative_to)
try:
start = start.resolve()
start = start_path.resolve()
except OSError:
start = start.absolute()
start = start_path.absolute()

# check if there is a drive letter or mount point
# if it is a mountpoint use the original absolute path
# instead of the unc path
if check_for_unc_path(start):
start = start_path.absolute()

path = start.joinpath(path).relative_to(start)

# check and see if the path that was passed into the function is a UNC path
# and raise value error if it is not.
if check_for_unc_path(path):
raise ValueError("The path argument does not currently accept UNC paths")

relpath_s = posixpath.normpath(path.as_posix())
if not (relpath_s == "." or relpath_s.startswith("./")):
relpath_s = posixpath.join(".", relpath_s)
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ requests==2.19.1
idna==2.7
urllib3==1.23
certifi==2018.4.16
requirementslib==1.0.10
requirementslib==1.0.11
attrs==18.1.0
distlib==0.2.7
packaging==17.1
Expand Down