diff --git a/pipenv/vendor/requirementslib/__init__.py b/pipenv/vendor/requirementslib/__init__.py index ef4d46a8d2..5f3a5eb006 100644 --- a/pipenv/vendor/requirementslib/__init__.py +++ b/pipenv/vendor/requirementslib/__init__.py @@ -1,4 +1,4 @@ # -*- coding=utf-8 -*- -__version__ = "0.0.4" +__version__ = "0.0.5" from .requirements import Requirement diff --git a/pipenv/vendor/requirementslib/requirements.py b/pipenv/vendor/requirementslib/requirements.py index 04e561c6d3..f7d78b0978 100644 --- a/pipenv/vendor/requirementslib/requirements.py +++ b/pipenv/vendor/requirementslib/requirements.py @@ -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}" @@ -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") @@ -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 @@ -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, diff --git a/pipenv/vendor/requirementslib/utils.py b/pipenv/vendor/requirementslib/utils.py index b9358a35b5..8035b87891 100644 --- a/pipenv/vendor/requirementslib/utils.py +++ b/pipenv/vendor/requirementslib/utils.py @@ -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 @@ -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): diff --git a/pipenv/vendor/vendor.txt b/pipenv/vendor/vendor.txt index 94d9eb231a..0d236fbe44 100644 --- a/pipenv/vendor/vendor.txt +++ b/pipenv/vendor/vendor.txt @@ -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