From b5045155a7b6eff5cd2a5736e29a28e47f29659c Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Fri, 21 Oct 2022 13:37:20 +0200 Subject: [PATCH] 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 66c53545..15cf939e 100644 --- a/pipenv/environment.py +++ b/pipenv/environment.py @@ -311,19 +311,12 @@ class Environment: 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 4368f6c3..a8765e29 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: