]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
python: use posix_prefix instead of posix_local on Debian.
authorGianfranco Costamagna <locutusofborg@debian.org>
Wed, 17 Jan 2024 22:48:13 +0000 (14:48 -0800)
committerKarl Berry <karl@freefriends.org>
Wed, 17 Jan 2024 22:48:13 +0000 (14:48 -0800)
From https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54412#17.
(Patch slightly adapted by Bogdan from original by Gianfranco,
as posted by Stefano Rivera in message#14.)

* m4/python.m4 (AM_PATH_PYTHON): replace Debian's posix_local
scheme with posix_prefix.
* doc/automake.texi (Python) <pythondir>: say a bit more.
* NEWS: mention this.

NEWS
doc/automake.texi
m4/python.m4

diff --git a/NEWS b/NEWS
index c53573a0abbbd02967e856e2f87b9dd573a40a31..2b2da0908db94485e4656bdfa25abdb8dabd6074 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,7 +50,7 @@ New in 1.17:
     well as a Perl, sleep utility, and filesystem that supports
     sub-second resolution; otherwise, we fall back to one-second
     granularity as before. When everything is supported, a line
-    `Features: subsecond-mtime' is now printed by automake --version
+    "Features: subsecond-mtime" is now printed by automake --version
     and autom4te --version. (bug#64756, bug#67670)
 
   - The default value of $ARFLAGS is now "cr" instead of "cru", to better
@@ -61,12 +61,17 @@ New in 1.17:
     only for compression, not decompression, because of the same system.
     (bug#68151)
 
-  - Dependency files are now empty, instead of '# dummy', for speed.
+  - Dependency files are now empty, instead of "# dummy", for speed.
     (https://lists.gnu.org/archive/html/automake/2022-05/msg00006.html)
 
   - Compiling Python modules with Python 3.5+ uses multiple optimization
     levels. (bug#38043)
 
+  - The installation directory for Python files again defaults to
+    "site-packages" under the usual installation prefix, even on systems
+    (generally Debian-based) that would normally use the "dist-packages"
+    subdirectory under /usr/local. (bug#54412, bug#64837)
+
   - When compiling Emacs Lisp files, emacs is run with --no-site-file to
     disable user config files that might hang or access the terminal;
     and -Q is not used, since its support and behavior varies. (bug#58102)
index c63279a9e66d3178f14c55de526597e616793583..ecefe2dc6200b0fcf4e7eb4d13ab7dd3d844b1c4 100644 (file)
@@ -7987,8 +7987,18 @@ building Python extensions.
 
 @item pythondir
 @cindex @file{site-packages} Python directory
-The directory name for the @file{site-packages} subdirectory of the
-standard Python install tree.
+@cindex @file{dist-packages} Python directory
+The subdirectory of the Python install tree in which to install Python
+scripts. By default this is, on all systems,
+@file{$PYTHON_PREFIX/lib/python@var{version}/site-packages}, where
+@code{$PYTHON_PREFIX} is described above, and @var{version} is the
+Python version.  (For those knowledgeable about Python installation
+details: systems generally have their own Python installation scheme,
+such as @code{posix_local} on Debian and related (as of
+Python@tie{}3.10), which ends up using a directory named
+@file{dist-packages}; Automake uses the @code{posix_prefix} scheme and
+@file{site-packages}.)
+@c https://bugs.gnu.org/54412 et al.
 
 @item pkgpythondir
 This is the directory under @code{pythondir} that is named after the
index 2de57c52ae813b0b5293a75d265b3d1061b7bae0..f90c73d9314602d2c753dd96f40b4789803a71af 100644 (file)
@@ -243,9 +243,9 @@ except ImportError:
 
   dnl 1. pythondir: where to install python scripts.  This is the
   dnl    site-packages directory, not the python standard library
-  dnl    directory like in previous automake betas.  This behavior
+  dnl    directory as in early automake betas.  This behavior
   dnl    is more consistent with lispdir.m4 for example.
-  dnl Query distutils for this directory.
+  dnl Query sysconfig or distutils (per above) for this directory.
   dnl
   AC_CACHE_CHECK([for $am_display_PYTHON script directory (pythondir)],
   [am_cv_python_pythondir],
@@ -257,7 +257,19 @@ 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'})
+  try:
+    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
+      # follow the prefix, as we always have.
+      # See bugs#54412, #64837, et al.
+      scheme = 'posix_prefix'
+    sitedir = sysconfig.get_path('purelib', scheme, vars={'base':'$am_py_prefix'})
+  except:
+    sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
 else:
   from distutils import sysconfig
   sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
@@ -287,7 +299,7 @@ sys.stdout.write(sitedir)"`
 
   dnl 3. pyexecdir: directory for installing python extension modules
   dnl    (shared libraries).
-  dnl Query distutils for this directory.
+  dnl Query sysconfig or distutils for this directory.
   dnl
   AC_CACHE_CHECK([for $am_display_PYTHON extension module directory (pyexecdir)],
   [am_cv_python_pyexecdir],
@@ -299,7 +311,17 @@ 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'})
+  try:
+    if hasattr(sysconfig, 'get_default_scheme'):
+      scheme = sysconfig.get_default_scheme()
+    else:
+      scheme = sysconfig._get_default_scheme()
+    if scheme == 'posix_local':
+      # See scheme comments above.
+      scheme = 'posix_prefix'
+    sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase':'$am_py_exec_prefix'})
+  except:
+    sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_exec_prefix'})
 else:
   from distutils import sysconfig
   sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_exec_prefix')