mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Rewrite Environment.sys_path
Use `pipenv.utils.shell.load_path` instead of using `vistir.misc.run`
This commit is contained in:
+4
-11
@@ -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(
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user