Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
fix virtualenv sysconfig prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Dec 21, 2021
1 parent c95452e commit 9b93d73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
44 changes: 22 additions & 22 deletions debian/patches/deb-locations.diff
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Subject: deb-locations
---
Lib/distutils/command/install.py | 4 ++--
Lib/pydoc.py | 4 ++++
Lib/sysconfig.py | 47 +++++++++++++++++++++++++++++++++++-----
Lib/sysconfig.py | 46 +++++++++++++++++++++++++++++++++++-----
Misc/python.man | 2 +-
4 files changed, 49 insertions(+), 8 deletions(-)
4 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 01d5331..d25b82f 100644
Expand Down Expand Up @@ -45,10 +45,10 @@ index 4a8c10a..af16580 100755

This can be overridden by setting the PYTHONDOCS environment variable
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index daf9f00..8a4e919 100644
index daf9f00..908ea48 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -56,6 +56,26 @@ _INSTALL_SCHEMES = {
@@ -56,7 +56,28 @@ _INSTALL_SCHEMES = {
'scripts': '{base}/Scripts',
'data': '{base}',
},
Expand All @@ -73,9 +73,11 @@ index daf9f00..8a4e919 100644
+ 'data': '{base}',
+ },
}
+_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_prefix']


@@ -237,11 +257,28 @@ def _get_preferred_schemes():
# NOTE: site.py has copy of this function.
@@ -237,11 +258,26 @@ def _get_preferred_schemes():
'home': 'posix_home',
'user': 'osx_framework_user',
}
Expand All @@ -84,28 +86,26 @@ index daf9f00..8a4e919 100644
- 'home': 'posix_home',
- 'user': 'posix_user',
- }
+ if 'real_prefix' in sys.__dict__ or 'VIRTUAL_ENV' in os.environ:
+ # virtual environments
+ # virtual environments
+ if hasattr(sys, 'real_prefix') or sys.base_prefix != sys.prefix:
+ return {
+ 'prefix': 'posix_prefix',
+ 'prefix': 'venv',
+ 'home': 'posix_home',
+ 'user': 'posix_user',
+ }
+ # default to /usr for package builds, /usr/local otherwise
+ elif os.environ.get('DEB_PYTHON_INSTALL_LAYOUT') in ('deb', 'deb_system'):
+ return {
+ 'prefix': 'deb_system',
+ 'home': 'posix_home',
+ 'user': 'posix_user',
+ }
+ else:
+ # default to /usr for package builds, /usr/local otherwise
+ deb_build = os.environ.get('DEB_PYTHON_INSTALL_LAYOUT', 'posix_local')
+ if deb_build in ('deb', 'deb_system'):
+ return {
+ 'prefix': 'deb_system',
+ 'home': 'posix_home',
+ 'user': 'posix_user',
+ }
+ else:
+ return {
+ 'prefix': 'posix_local',
+ 'home': 'posix_home',
+ 'user': 'posix_user',
+ }
+ return {
+ 'prefix': 'posix_local',
+ 'home': 'posix_home',
+ 'user': 'posix_user',
+ }


def get_preferred_scheme(key):
Expand Down
4 changes: 2 additions & 2 deletions debian/patches/multiarch.diff
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ index 6f086be..da46770 100644
elif os.name == "nt":
if python_build:
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 8a4e919..2a22492 100644
index 908ea48..2fc8cbe 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -660,6 +660,12 @@ def get_config_vars(*args):
@@ -659,6 +659,12 @@ def get_config_vars(*args):
# the init-function.
_CONFIG_VARS['userbase'] = _getuserbase()

Expand Down

0 comments on commit 9b93d73

Please sign in to comment.