Subject: bug#54412: closed (Re: [bug#54412] [PATCH] python: use the posix_prefix sysconfig scheme on Debian)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 23 Jan 2024 21:51:03 +0000

Your bug report

#54412: [PATCH] python: use the posix_prefix sysconfig scheme on Debian

which was filed against the automake-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
54412: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54412
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#54412] [PATCH] python: use the posix_prefix sysconfig scheme on Debian
From: Karl Berry <[email-masked]>
To: [email-masked], [email-masked]
Date: Tue, 23 Jan 2024 14:49:50 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Guess it's time to close this one about the Python scheme to use with
Debian. We'll see how it turns out with the next pretest ... --thanks, karl.

Subject: [PATCH] python: use the posix_prefix sysconfig scheme on Debian
From: Stefano Rivera <[email-masked]>
To: [email-masked]
Cc: Gianfranco Costamagna <[email-masked]>, Stefano Rivera <[email-masked]>
Date: Tue, 15 Mar 2022 19:30:56 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Fixes Debian's bug: https://bugs.debian.org/1006784

Debian adds a custom sysconfig scheme to system python installs,
"posix_local". This is the default scheme, and it redirects local users'
Python module installs to /usr/local even though Python is installed
with a /usr prefix. Both are on Debian's python's sys.path module search
path.

Automake and its users understand prefixes, and are likely to select
/usr/local, explicitly. Select the "posix_prefix" scheme, with the
user-supplied prefix.

Previously this custom sysconfig scheme was specified in
distutils.sysconfig, but not sysconfig itself. As distutils is being
deprecated, the custom scheme is now specified in sysconfig, since
Debian's Python 3.10 (3.10.2-4).

Thank you, Gianfranco Costamagna <[email-masked]>, for porting
the patch to automake.

* m4/python.m4: use the posix_prefix sysconfig scheme on Debian

Copyright-paperwork-exempt: yes
---
 m4/python.m4 | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/m4/python.m4 b/m4/python.m4
index 6653e4d89..51e050c19 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -255,7 +255,11 @@ except ImportError:
    am_cv_python_pythondir=`$PYTHON -c "
 $am_python_setup_sysconfig
 if can_use_sysconfig:
-  sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+  scheme = sysconfig.get_default_scheme()
+  if scheme == 'posix_local':
+    # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
+    scheme = 'posix_prefix'
+  sitedir = sysconfig.get_path('purelib', scheme, vars={'base':'$am_py_prefix'})
 else:
   from distutils import sysconfig
   sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
@@ -297,7 +301,11 @@ sys.stdout.write(sitedir)"`
    am_cv_python_pyexecdir=`$PYTHON -c "
 $am_python_setup_sysconfig
 if can_use_sysconfig:
-  sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_exec_prefix'})
+  scheme = sysconfig.get_default_scheme()
+  if scheme == 'posix_local':
+    # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
+    scheme = 'posix_prefix'
+  sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase':'$am_py_exec_prefix'})
 else:
   from distutils import sysconfig
   sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_exec_prefix')
-- 
2.35.1