diff --git a/Pipfile b/Pipfile index 2e6eb1a8..f1c2263c 100644 --- a/Pipfile +++ b/Pipfile @@ -25,9 +25,9 @@ myst-parser = {extras = ["linkify"], version = "*"} invoke = "==2.0.0" exceptiongroup = "==1.1.0" tomli = "*" -pytz = "*" [packages] +pytz = "*" [scripts] tests = "bash ./run-tests.sh" diff --git a/pipenv/vendor/requirementslib/models/requirements.py b/pipenv/vendor/requirementslib/models/requirements.py index 6293e1c0..69603a3d 100644 --- a/pipenv/vendor/requirementslib/models/requirements.py +++ b/pipenv/vendor/requirementslib/models/requirements.py @@ -1,7 +1,6 @@ import collections import copy import os -import re import sys from contextlib import contextmanager from functools import lru_cache @@ -135,6 +134,13 @@ class Line(object): def __init__(self, line, extras=None): # type: (AnyStr, Optional[Union[List[S], Set[S], Tuple[S, ...]]]) -> None self.editable = False # type: bool + if line.startswith("-e "): + line = line[len("-e ") :] + self.editable = True + self.extras = () # type: Tuple[STRING_TYPE, ...] + if extras is not None: + self.extras = tuple(sorted(set(extras))) + self.line = line # type: STRING_TYPE self.hashes = [] # type: List[STRING_TYPE] self.markers = None # type: Optional[STRING_TYPE] self.vcs = None # type: Optional[STRING_TYPE] @@ -161,20 +167,7 @@ class Line(object): self._ireq = None # type: Optional[InstallRequirement] self._src_root = None # type: Optional[STRING_TYPE] self.dist = None # type: Any - self.line = line # type: STRING_TYPE super(Line, self).__init__() - self.extras = () # type: Tuple[STRING_TYPE, ...] - if extras is not None: - self.extras = tuple(sorted(set(extras))) - if line.startswith("-e "): - self.line = line = line[len("-e "):] - # Regular expression to match the path without extras - path_pattern = re.compile(r"^[^\[]+") - # Extract the path without extras - self.line = line = path_pattern.match(line).group(0) - self.editable = True - self.path = os.path.abspath(line) - self.setup_info = self.get_setup_info() self.parse() def __hash__(self): @@ -223,10 +216,10 @@ class Line(object): hash_list = ["--hash={0}".format(h) for h in sorted(self.hashes)] if self.is_named: line = self.name_and_specifier - elif self.is_direct_url and self.link: + elif self.is_direct_url: line = self.link.url elif extras_str: - if self.is_vcs and self.link: + if self.is_vcs: line = self.link.url if "git+file:/" in line and "git+file:///" not in line: line = line.replace("git+file:/", "git+file:///") @@ -342,7 +335,7 @@ class Line(object): line = self.path if self.extras: line = "{0}{1}".format(line, extras_to_string(self.extras)) - elif self.link: + else: line = self.link.url elif self.is_vcs and not self.editable: line = add_ssh_scheme_to_git_uri(self.line) @@ -1028,12 +1021,11 @@ class Line(object): if "&" in name: # subdirectory fragments might also be in here name, _, _ = name.partition("&") - - if name is None and (self.is_file or self.is_remote_url or self.is_path): + if name is None and self.is_named: + name = self._parse_name_from_line() + elif name is None and (self.is_file or self.is_remote_url or self.is_path): if self.is_local: name = self._parse_name_from_path() - elif name is None and self.is_named: - name = self._parse_name_from_line() if name is not None: name, extras = _strip_extras(name) if extras is not None and not self.extras: diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 2eba0a19..928ff397 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -309,8 +309,12 @@ class _PipenvInstance: if name is not None: path = Path(os.environ["HOME"]) / "projects" / name path.mkdir(exist_ok=True) - self.path = path = os.path.abspath(".") - self._path = Path(path) + self._path = path = TemporaryDirectory(prefix='pipenv-', suffix='-project') + path = Path(self._path.name) + try: + self.path = str(path.resolve()) + except OSError: + self.path = str(path.absolute()) # set file creation perms self.pipfile_path = None @@ -359,9 +363,12 @@ class _PipenvInstance: os.environ['PIPENV_PIPFILE'] = self.pipfile_path # a bit of a hack to make sure the virtualenv is created - cmd_args = shlex.split(cmd) - r = cli_runner.invoke(cli, cmd_args, env=self.env) - r.returncode = r.exit_code + with TemporaryDirectory(prefix='pipenv-', suffix='-cache') as tempdir: + cmd_args = shlex.split(cmd) + env = {**self.env, **{'PIPENV_CACHE_DIR': tempdir}} + self.capfd.readouterr() + r = cli_runner.invoke(cli, cmd_args, env=env) + r.returncode = r.exit_code # Pretty output for failing tests. out, err = self.capfd.readouterr() if out: