Blob Blame History Raw
From 4673c785aca8a25c36628fe33fa82ff942564c59 Mon Sep 17 00:00:00 2001
From: Tomas Orsava <torsava@redhat.com>
Date: Tue, 3 May 2022 17:04:39 +0200
Subject: [PATCH] Make pipenv work with the `venv` install scheme if it is
 detected

---
 pipenv/environment.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/pipenv/environment.py b/pipenv/environment.py
index 2261bf20..4cf0682d 100644
--- a/pipenv/environment.py
+++ b/pipenv/environment.py
@@ -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_scheme_names, get_python_version
 
 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,
-- 
2.35.1