Merge pull request #5096 from torsava/venv-fix

Make pipenv work with the `venv` install scheme if it is detected
This commit is contained in:
Matt Davis
2022-05-26 15:50:40 -04:00
committed by GitHub
3 changed files with 15 additions and 8 deletions
-1
View File
@@ -8,7 +8,6 @@ concurrency:
on:
push:
paths-ignore:
- "news/**"
- "examples/**"
- "peeps/**"
- "*.ini"
+2
View File
@@ -0,0 +1,2 @@
Adjust pipenv to work with the newly added ``venv`` install scheme in Python.
First check if ``venv`` is among the available install schemes, and use it if it is. Otherwise fall back to the ``nt`` or ``posix_prefix`` install schemes as before. This should produce no change for environments where the install schemes were not redefined.
+13 -7
View File
@@ -7,7 +7,7 @@ import os
import site
import sys
from pathlib import Path
from sysconfig import get_paths, get_python_version
from sysconfig import get_paths, get_python_version, get_scheme_names
import pkg_resources
@@ -174,6 +174,15 @@ class Environment:
return os.path.join(base, leaf)
return path
@cached_property
def install_scheme(self):
if "venv" in get_scheme_names():
return "venv"
elif os.name == "nt":
return "nt"
else:
return "posix_prefix"
@cached_property
def base_paths(self):
# type: () -> Dict[str, str]
@@ -213,9 +222,8 @@ class Environment:
try:
paths = self.get_paths()
except Exception:
install_scheme = "nt" if (os.name == "nt") else "posix_prefix"
paths = get_paths(
install_scheme,
self.install_scheme,
vars={
"base": prefix,
"platbase": prefix,
@@ -236,9 +244,8 @@ class Environment:
paths.update(self.get_lib_paths())
paths["scripts"] = self.script_basedir
if not paths:
install_scheme = "nt" if (os.name == "nt") else "posix_prefix"
paths = get_paths(
install_scheme,
self.install_scheme,
vars={
"base": prefix,
"platbase": prefix,
@@ -266,9 +273,8 @@ class Environment:
# type: () -> str
"""Path to the environment scripts dir"""
prefix = make_posix(self.prefix.as_posix())
install_scheme = "nt" if (os.name == "nt") else "posix_prefix"
paths = get_paths(
install_scheme,
self.install_scheme,
vars={
"base": prefix,
"platbase": prefix,