Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pipenv work with the venv install scheme if it is detected #5096

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ concurrency:
on:
push:
paths-ignore:
- "news/**"
- "examples/**"
- "peeps/**"
- "*.ini"
Expand Down
2 changes: 2 additions & 0 deletions news/5096.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 13 additions & 7 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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

Expand Down Expand Up @@ -174,6 +174,15 @@ def _replace_parent_version(self, path, replace_version):
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]
Expand Down Expand Up @@ -213,9 +222,8 @@ def base_paths(self):
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,
Expand All @@ -236,9 +244,8 @@ def base_paths(self):
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,
Expand Down Expand Up @@ -266,9 +273,8 @@ def script_basedir(self):
# 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,
Expand Down