Skip to content

Commit

Permalink
latest changes to requirementslib. Revert back to vistir for create_t…
Browse files Browse the repository at this point in the history
…racked_tempfile.
  • Loading branch information
matteius committed Aug 8, 2022
1 parent 710ad78 commit 9583f41
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
5 changes: 3 additions & 2 deletions pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from contextlib import contextmanager
from tempfile import NamedTemporaryFile
from typing import Mapping, Sequence

from pipenv.patched.pip._vendor.packaging.markers import Marker
Expand Down Expand Up @@ -272,7 +271,9 @@ def convert_deps_to_pip(
return dependencies

# Write requirements.txt to tmp directory.
f = NamedTemporaryFile(suffix="-requirements.txt", delete=False)
from pipenv.vendor.vistir.path import create_tracked_tempfile

f = create_tracked_tempfile(suffix="-requirements.txt", delete=False)
f.write("\n".join(dependencies).encode("utf-8"))
f.close()
return f.name
Expand Down
63 changes: 27 additions & 36 deletions pipenv/vendor/requirementslib/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,25 +558,26 @@ def parse_extras(self):
:rtype: :class:`~Line`
"""
extras = None
line = "{0}".format(self.line)
if any([self.is_vcs, self.is_url, "@" in line]):
try:
if self.parsed_url.name:
self._name = self.parsed_url.name
if (
self.parsed_url.host
and self.parsed_url.path
and self.parsed_url.scheme
):
self.line = self.parsed_url.to_string(
escape_password=False,
direct=False,
strip_ssh=self.parsed_url.is_implicit_ssh,
)
except ValueError:
if not self.line:
line = "{0}".format(self.line)
if any([self.is_vcs, self.is_url, "@" in line]):
try:
if self.parsed_url.name:
self._name = self.parsed_url.name
if (
self.parsed_url.host
and self.parsed_url.path
and self.parsed_url.scheme
):
self.line = self.parsed_url.to_string(
escape_password=False,
direct=False,
strip_ssh=self.parsed_url.is_implicit_ssh,
)
except ValueError:
self.line, extras = _strip_extras(self.line)
else:
self.line, extras = _strip_extras(self.line)
else:
self.line, extras = _strip_extras(self.line)
extras_set = set() # type: Set[STRING_TYPE]
if extras is not None:
extras_set = set(parse_extras(extras))
Expand All @@ -587,7 +588,6 @@ def parse_extras(self):
extras_set |= name_extras
if extras_set is not None:
self.extras = tuple(sorted(extras_set))
return self

def get_url(self):
# type: () -> STRING_TYPE
Expand Down Expand Up @@ -850,14 +850,12 @@ def vcsrepo(self):
self._vcsrepo = self._get_vcsrepo()
return self._vcsrepo

@property
@cached_property
def parsed_url(self):
# type: () -> URI
if self._parsed_url is None:
self._parsed_url = URI.parse(self.line)
return self._parsed_url
return URI.parse(self.line)

@property
@cached_property
def is_direct_url(self):
# type: () -> bool
try:
Expand Down Expand Up @@ -1177,7 +1175,6 @@ def parse_link(self):
self._link = parsed_link
else:
self._link = link
return self

def parse_markers(self):
# type: () -> None
Expand Down Expand Up @@ -2523,7 +2520,10 @@ def get_line_instance(self):
else:
line_parts.append(self.req.line_part)
if not self.is_vcs and not self.vcs and self.extras_as_pip:
line_parts.append(self.extras_as_pip)
if self.is_file_or_url:
line_parts.append(f"#egg={self.extras_as_pip}")
else:
line_parts.append(self.extras_as_pip)
if self._specifiers and not (self.is_file_or_url or self.is_vcs):
line_parts.append(self._specifiers)
if self.markers:
Expand All @@ -2545,16 +2545,7 @@ def get_line_instance(self):
@property
def line_instance(self):
# type: () -> Optional[Line]
if self._line_instance is None:
self.line_instance = self.get_line_instance()
return self._line_instance

@line_instance.setter
def line_instance(self, line_instance):
# type: (Line) -> None
if self.req:
self.req._parsed_line = line_instance
self._line_instance = line_instance
return self.get_line_instance()

@property
def specifiers(self):
Expand Down
4 changes: 1 addition & 3 deletions pipenv/vendor/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,9 +1532,7 @@ def from_ireq(cls, ireq, subdir=None, finder=None, session=None):
uri = uri.replace("file:/", "file:///")
path = url_to_path(uri)
kwargs = _prepare_wheel_building_kwargs(ireq)
is_artifact_or_vcs = getattr(
ireq.link, "is_vcs", getattr(ireq.link, "is_artifact", False)
)
is_artifact_or_vcs = getattr(ireq.link, "is_vcs", False)
is_vcs = True if vcs else is_artifact_or_vcs
download_dir = None
if not (ireq.editable and is_file and is_vcs):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"extras": ["voice"],
}
},
"https://github.com/Rapptz/discord.py/archive/async.zip#egg=discord.py[voice]",
"https://github.com/Rapptz/discord.py/archive/async.zip#egg=[voice]",
),
(
{
Expand Down

0 comments on commit 9583f41

Please sign in to comment.