Package: autoconf-archive
Version: 20220211-2
Severity: normal
Tags: patch
Forwarded: https://savannah.gnu.org/patch/index.php?10272

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.

Autoconf 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).


Test-case attached, from minimezd from graph-tools. I think to get the
plugin to work, out of the box, with Python 3.10, we need some other
patches too: https://savannah.gnu.org/patch/?group=autoconf-archive

SR
From 118f689596966f294c2d1fd7ccc99157b9542056 Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Sun, 28 Aug 2022 18:43:54 +0200
Subject: [PATCH 1/2] Support Debian's posix_local sysconfig scheme in
 ax_python_devel

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.

Autoconf 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).
---
 m4/ax_python_devel.m4 | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4
index 0a71592f..eabfeeb0 100644
--- a/m4/ax_python_devel.m4
+++ b/m4/ax_python_devel.m4
@@ -295,8 +295,20 @@ EOD`
 	AC_MSG_CHECKING([for Python site-packages path])
 	if test -z "$PYTHON_SITE_PKG"; then
 		if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
-			PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
-				print (sysconfig.get_path('purelib'));"`
+			PYTHON_SITE_PKG=`$PYTHON -c "
+$IMPORT_SYSCONFIG;
+if hasattr(sysconfig, 'get_default_scheme'):
+    scheme = sysconfig.get_default_scheme()
+else:
+    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'
+prefix = '$prefix'
+if prefix == 'NONE':
+    prefix = '$ac_default_prefix'
+sitedir = sysconfig.get_path('purelib', scheme, vars={'base': prefix})
+print(sitedir)"`
 		else
 			# distutils.sysconfig way
 			PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
@@ -312,8 +324,20 @@ EOD`
 	AC_MSG_CHECKING([for Python platform specific site-packages path])
 	if test -z "$PYTHON_SITE_PKG"; then
 		if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
-			PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
-				print (sysconfig.get_path('platlib'));"`
+			PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "
+$IMPORT_SYSCONFIG;
+if hasattr(sysconfig, 'get_default_scheme'):
+    scheme = sysconfig.get_default_scheme()
+else:
+    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'
+prefix = '$prefix'
+if prefix == 'NONE':
+    prefix = '$ac_default_prefix'
+sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase': prefix})
+print(sitedir)"`
 		else
 			# distutils.sysconfig way
 			PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
-- 
2.35.1

Attachment: configure.ac
Description: application/pkix-attr-cert

Reply via email to