Skip to content

Commit

Permalink
Merge pull request #5430 from pypa/remove-usage-of-vistir-run
Browse files Browse the repository at this point in the history
Rewrite Environment.sys_path without vistir.misc.run
  • Loading branch information
oz123 authored Oct 24, 2022
2 parents 3e6dcfd + b504515 commit 35dc409
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
15 changes: 4 additions & 11 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions pipenv/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 35dc409

Please sign in to comment.