Skip to content

Commit

Permalink
Merge pull request #5078 from pypa/more-vistir-dropping
Browse files Browse the repository at this point in the history
More vistir dropping
  • Loading branch information
matteius authored Apr 25, 2022
2 parents b5c7c1e + fe552a0 commit 295fb30
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions news/5078.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove more usage of misc functions of vistir. Many of this function are availabel in the STL or in another dependency of pipenv.
7 changes: 4 additions & 3 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import shutil
import sys
import tempfile
import time
import warnings
from pathlib import Path
Expand Down Expand Up @@ -1394,7 +1395,7 @@ def get_pip_args(
arg_set.extend(arg_map.get(key))
elif key == "selective_upgrade" and not locals().get(key):
arg_set.append("--exists-action=i")
return list(vistir.misc.dedup(arg_set))
return list(dict.fromkeys(arg_set))


def get_requirement_line(
Expand Down Expand Up @@ -1440,7 +1441,7 @@ def write_requirement_to_file(
with_prefix=True, with_hashes=include_hashes, with_markers=True, as_list=False
)

f = vistir.compat.NamedTemporaryFile(
f = tempfile.NamedTemporaryFile(
prefix="pipenv-", suffix="-requirement.txt", dir=requirements_dir, delete=False
)
if project.s.is_verbose():
Expand Down Expand Up @@ -1844,11 +1845,11 @@ def do_py(project, ctx=None, system=False):
def do_outdated(project, pypi_mirror=None, pre=False, clear=False):
# TODO: Allow --skip-lock here?
from collections import namedtuple
from collections.abc import Mapping

from .vendor.packaging.utils import canonicalize_name
from .vendor.requirementslib.models.requirements import Requirement
from .vendor.requirementslib.models.utils import get_version
from .vendor.vistir.compat import Mapping

packages = {}
package_info = namedtuple("PackageInfo", ["name", "installed", "available"])
Expand Down
14 changes: 7 additions & 7 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pipenv.utils.indexes import prepare_pip_source_args
from pipenv.utils.processes import subprocess_run
from pipenv.utils.shell import make_posix, normalize_path
from pipenv.vendor import vistir
from pipenv.vendor import click, vistir
from pipenv.vendor.cached_property import cached_property
from pipenv.vendor.packaging.utils import canonicalize_name

Expand Down Expand Up @@ -410,8 +410,8 @@ def get_paths(self):
paths[key] = make_posix(paths[key])
return paths
else:
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
click.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
click.echo(f"Output: {c.stdout}", fg="yellow")
return None

def get_lib_paths(self):
Expand Down Expand Up @@ -439,8 +439,8 @@ def get_lib_paths(self):
paths[key] = make_posix(paths[key])
return paths
else:
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
click.secho(f"Failed to load paths: {c.stderr}", fg="yellow")
click.secho(f"Output: {c.stdout}", fg="yellow")
if not paths:
if not self.prefix.joinpath("lib").exists():
return {}
Expand Down Expand Up @@ -499,8 +499,8 @@ def get_include_path(self):
paths[key] = make_posix(paths[key])
return paths
else:
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
click.secho(f"Failed to load paths: {c.stderr}", fg="yellow")
click.secho(f"Output: {c.stdout}", fg="yellow")
return None

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def marker_to_str(marker):

if not marker:
return None
from pipenv.vendor.vistir.compat import Mapping
from collections.abc import Mapping

marker_str = None
if isinstance(marker, Mapping):
Expand Down
3 changes: 2 additions & 1 deletion pipenv/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import signal
import subprocess
import sys
from pathlib import Path

from pipenv.vendor import shellingham
from pipenv.vendor.vistir.compat import Path, get_terminal_size
from pipenv.vendor.vistir.compat import get_terminal_size
from pipenv.vendor.vistir.contextmanagers import temp_environ

ShellDetectionFailure = shellingham.ShellDetectionFailure
Expand Down
4 changes: 2 additions & 2 deletions pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def translate_markers(pipfile_entry):
if not isinstance(pipfile_entry, Mapping):
raise TypeError("Entry is not a pipfile formatted mapping.")
from pipenv.vendor.packaging.markers import default_environment
from pipenv.vendor.vistir.misc import dedup

allowed_marker_keys = ["markers"] + list(default_environment().keys())
provided_keys = list(pipfile_entry.keys()) if hasattr(pipfile_entry, "keys") else []
Expand All @@ -153,7 +152,8 @@ def translate_markers(pipfile_entry):
new_pipfile["markers"] = str(
Marker(
" or ".join(
f"{s}" if " and " in s else s for s in sorted(dedup(marker_set))
f"{s}" if " and " in s else s
for s in sorted(dict.fromkeys(marker_set))
)
)
).replace('"', "'")
Expand Down
7 changes: 5 additions & 2 deletions pipenv/utils/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,10 +943,11 @@ def venv_resolve_deps(
"""

import json
import tempfile

from pipenv import resolver
from pipenv._compat import decode_for_output
from pipenv.vendor.vistir.compat import NamedTemporaryFile, Path
from pipenv.vendor.vistir.compat import Path

results = []
pipfile_section = "dev-packages" if dev else "packages"
Expand Down Expand Up @@ -975,7 +976,9 @@ def venv_resolve_deps(
cmd.append("--system")
if dev:
cmd.append("--dev")
target_file = NamedTemporaryFile(prefix="resolver", suffix=".json", delete=False)
target_file = tempfile.NamedTemporaryFile(
prefix="resolver", suffix=".json", delete=False
)
target_file.close()
cmd.extend(["--write", make_posix(target_file.name)])
with temp_environ():
Expand Down

0 comments on commit 295fb30

Please sign in to comment.