Revert "work towards fixing relative path . with extras"

This reverts commit 724364d241.
This commit is contained in:
Matt Davis
2023-04-26 22:43:54 -04:00
parent d89da7fe59
commit 89f554622a
3 changed files with 26 additions and 27 deletions
+1 -1
View File
@@ -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"
+13 -21
View File
@@ -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:
+12 -5
View File
@@ -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: