From eaeef7df431909581b552781053668c15db3db08 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Fri, 21 Oct 2022 10:55:12 +0200 Subject: [PATCH 1/2] Replace vistir.misc.replace_with_text_stream with click The rational here is that click has a broader user base then vistir, and *if* bugs are encountered they will fixed there in a quicker manner. --- pipenv/resolver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pipenv/resolver.py b/pipenv/resolver.py index 467742c074..5280604990 100644 --- a/pipenv/resolver.py +++ b/pipenv/resolver.py @@ -819,11 +819,11 @@ def main(argv=None): _ensure_modules() import warnings - from pipenv.vendor.vistir.misc import replace_with_text_stream + from pipenv.vendor.click.utils import get_text_stream warnings.simplefilter("ignore", category=ResourceWarning) - replace_with_text_stream("stdout") - replace_with_text_stream("stderr") + sys.stdout = get_text_stream("stdout") + sys.stderr = get_text_stream("stderr") os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = "1" os.environ["PYTHONIOENCODING"] = "utf-8" os.environ["PYTHONUNBUFFERED"] = "1" From b5045155a7b6eff5cd2a5736e29a28e47f29659c Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Fri, 21 Oct 2022 13:37:20 +0200 Subject: [PATCH 2/2] Rewrite Environment.sys_path Use `pipenv.utils.shell.load_path` instead of using `vistir.misc.run` --- pipenv/environment.py | 15 ++++----------- pipenv/utils/shell.py | 3 +-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/pipenv/environment.py b/pipenv/environment.py index 66c53545d1..15cf939ec8 100644 --- a/pipenv/environment.py +++ b/pipenv/environment.py @@ -311,19 +311,12 @@ def sys_path(self) -> List[str]: return sys.path elif any([sys.prefix == self.prefix, not self.is_venv]): return sys.path - cmd_args = [self.python, "-c", "import json, sys; print(json.dumps(sys.path))"] - path, _ = vistir.misc.run( - cmd_args, - return_object=False, - nospin=True, - block=True, - combine_stderr=False, - write_to_stdout=False, - ) + try: - path = json.loads(path.strip()) - except json.JSONDecodeError: + path = pipenv.utils.shell.load_path(self.python) + except json.decoder.JSONDecodeError: path = sys.path + return path def build_command( diff --git a/pipenv/utils/shell.py b/pipenv/utils/shell.py index 4368f6c377..a8765e2987 100644 --- a/pipenv/utils/shell.py +++ b/pipenv/utils/shell.py @@ -73,8 +73,7 @@ def load_path(python): from pathlib import Path python = Path(python).as_posix() - json_dump_commmand = '"import json, sys; print(json.dumps(sys.path));"' - c = subprocess_run([python, "-c", json_dump_commmand]) + c = subprocess_run([python, "-c", "import json, sys; print(json.dumps(sys.path))"]) if c.returncode == 0: return json.loads(c.stdout.strip()) else: