Skip to content

Commit

Permalink
Update requirementslib to fix local path parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed May 25, 2018
1 parent b2611ef commit cecf6f8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pipenv/vendor/requirementslib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding=utf-8 -*-
__version__ = "0.0.4"
__version__ = "0.0.5"

from .requirements import Requirement
44 changes: 29 additions & 15 deletions pipenv/vendor/requirementslib/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
except ImportError:
from pathlib2 import Path

try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse

HASH_STRING = " --hash={0}"


Expand Down Expand Up @@ -261,7 +266,7 @@ def line_part(self):

@property
def pipfile_part(self):
pipfile_dict = attr.asdict(self, filter=_filter_none)
pipfile_dict = attr.asdict(self, filter=_filter_none).copy()
if "version" not in pipfile_dict:
pipfile_dict["version"] = "*"
name = pipfile_dict.pop("name")
Expand Down Expand Up @@ -305,16 +310,16 @@ def get_link(self):

@req.default
def get_requirement(self):
base = "{0}".format(self.link)
req = first(requirements.parse(base))
prefix = "-e " if self.editable else ""
line = "{0}{1}".format(prefix, self.link.url)
req = first(requirements.parse(line))
if self.path and self.link and self.link.scheme.startswith("file"):
req.local_file = True
req.path = self.path
req.uri = None
self._uri_scheme = "file"
if self.editable:
req.editable = True
if self.link and self.link.scheme.startswith("file"):
if self.path:
req.path = self.path
req.local_file = True
self._uri_scheme = "file"
req.uri = None
req.link = self.link
return req

Expand All @@ -338,15 +343,24 @@ def from_line(cls, line):
"Supplied requirement is not installable: {0!r}".format(line)
)

if is_valid_url(line):
if is_valid_url(line) and not is_installable_file(line):
link = Link(line)
else:
_path = Path(line)
link = Link(_path.absolute().as_uri())
if _path.is_absolute() or _path.as_posix() == ".":
path = _path.as_posix()
if is_valid_url(line):
parsed = urlparse(line)
link = Link('{0}'.format(line))
if parsed.scheme == "file":
path = Path(parsed.path).absolute().as_posix()
if get_converted_relative_path(path) == ".":
path = "."
line = path
else:
path = get_converted_relative_path(line)
_path = Path(line)
link = Link(_path.absolute().as_uri())
if _path.is_absolute() or _path.as_posix() == ".":
path = _path.as_posix()
else:
path = get_converted_relative_path(line)
arg_dict = {
"path": path,
"uri": link.url_without_fragment,
Expand Down
6 changes: 5 additions & 1 deletion pipenv/vendor/requirementslib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def is_installable_file(path):
else:
return False

parsed = urlparse(path)
if parsed.scheme == 'file':
path = parsed.path

if not os.path.exists(os.path.abspath(path)):
return False

Expand All @@ -90,7 +94,7 @@ def is_installable_file(path):
def is_valid_url(url):
"""Checks if a given string is an url"""
pieces = urlparse(url)
return all([pieces.scheme, pieces.netloc])
return all([pieces.scheme, any([pieces.netloc, pieces.path])])


def pep423_name(name):
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ requests==2.18.4
urllib3==1.22
certifi==2018.1.18
requirements-parser==0.2.0
requirementslib
requirementslib==0.0.5
six==1.10.0
semver==2.7.8
shutilwhich==1.1.0
Expand Down

0 comments on commit cecf6f8

Please sign in to comment.