Skip to content

Commit

Permalink
Dropped use of depricated python3-setuptools / distutils.
Browse files Browse the repository at this point in the history
Make sure sysconfig.get_path("platlib") return correct path on Debian
and Ubuntu systems, where /usr/lib/ should be used over
/usr/local/lib.

Based on e2c10a8 by Andy Pugh,

Fixes Debian issue #1080668.
  • Loading branch information
petterreinholdtsen committed Oct 20, 2024
1 parent b8c2d8a commit 862320c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
19 changes: 18 additions & 1 deletion src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,24 @@ fi
AC_MSG_RESULT([$PYTHON_TK_VERSION])

AC_MSG_CHECKING(for site-package location)
SITEPY=`$PYTHON -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())'`
case "$(lsb_release -is)" in
Debian|Ubuntu)

# Setting DEB_PYTHON_INSTALL_LAYOUT adjust sysconfig 'platlib' path, see
# <URL: https://bugs.debian.org/1080668 >. This affect SITEPY and
# might also affect AX_PYTHON and AX_PYTHON_DEVEL.

# The sed replacing python3.7 and similiar with python3 is to
# work with buster, which return version specific path.
# The sed replacing site-package to work with bullseye and
# older, which return ../site-packages, not .../dist-packages.
export DEB_PYTHON_INSTALL_LAYOUT=deb
SITEPY="$($PYTHON -c 'import sysconfig; import re; p2=sysconfig.get_path("platlib").replace("/site-packages", "/dist-packages"); print(re.sub(r"/python3[\.\d]+/","/python3/u", p2))')"
;;
*)
SITEPY=`$PYTHON -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())'`
;;
esac
AC_MSG_RESULT($SITEPY)

AC_MSG_CHECKING(for working GLU quadrics)
Expand Down
2 changes: 1 addition & 1 deletion src/m4/ax_python.m4
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if test x$ax_python_bin != x; then
AC_CHECK_LIB(${ax_python_bin}m, main, ax_python_lib=${ax_python_bin}m, ax_python_lib=no)
fi
if test x$ax_python_lib != xno; then
ax_python_header=`$ax_python_bin -c "from distutils.sysconfig import *; print(get_config_var('CONFINCLUDEPY'))"`
ax_python_header=`$ax_python_bin -c "import sysconfig; print(sysconfig.get_path('include'))"`
if test x$ax_python_header != x; then
break;
fi
Expand Down
33 changes: 8 additions & 25 deletions src/m4/ax_python_devel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -186,34 +186,23 @@ variable to configure. See ``configure --help'' for reference.
fi
fi
if test $ax_python_devel_found = yes; then
#
# Check if you have distutils, else fail
#
AC_MSG_CHECKING([for the sysconfig Python package])
ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1`
if test $? -eq 0; then
#
# Check if you have sysconfig, else fail
#
AC_MSG_CHECKING([for the sysconfig Python package])
ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1`
if test $? -eq 0; then
AC_MSG_RESULT([yes])
IMPORT_SYSCONFIG="import sysconfig"
else
AC_MSG_RESULT([no])
AC_MSG_CHECKING([for the distutils Python package])
ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1`
if test $? -eq 0; then
AC_MSG_RESULT([yes])
IMPORT_SYSCONFIG="from distutils import sysconfig"
else
AC_MSG_WARN([cannot import Python module "distutils".
else
AC_MSG_ERROR([cannot import Python module "sysconfig".
Please check your Python installation. The error was:
$ac_sysconfig_result])
if ! $ax_python_devel_optional; then
AC_MSG_ERROR([Giving up])
fi
ax_python_devel_found=no
PYTHON_VERSION=""
fi
fi
fi
if test $ax_python_devel_found = yes; then
Expand All @@ -228,12 +217,6 @@ $ac_sysconfig_result])
print (sysconfig.get_path ('include'));"`
plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_path ('platinclude'));"`
else
# old distutils way
python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_python_inc ());"`
plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_python_inc (plat_specific=1));"`
fi
if test -n "${python_path}"; then
if test "${plat_python_path}" != "${python_path}"; then
Expand Down

0 comments on commit 862320c

Please sign in to comment.