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 and
pull request LinuxCNC#3155 by Eckeneckepen.

Fixes Debian issue #1080668.
  • Loading branch information
petterreinholdtsen committed Oct 21, 2024
1 parent 673761a commit c8103d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
6 changes: 5 additions & 1 deletion debian/rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export PYTHON=/usr/bin/python3

override_dh_auto_configure:
cd src && ./autogen.sh
cd src && ./configure \
# Setting DEB_PYTHON_INSTALL_LAYOUT adjust sysconfig 'platlib' path,
# see <URL: https://bugs.debian.org/1080668 >. This affect
# configure.ac settings for SITEPY and might also affect AX_PYTHON and
# AX_PYTHON_DEVEL.
cd src && DEB_PYTHON_INSTALL_LAYOUT=deb ./configure \
--prefix=/usr --sysconfdir=/etc \
--mandir=/usr/share/man \
$(configure_realtime_arg) \
Expand Down
2 changes: 1 addition & 1 deletion src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ 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())'`
SITEPY="$($PYTHON -c 'import sysconfig; s = sysconfig.get_scheme_names(); m=list(set(("deb_system", "rpm_prefix")) & set(s)); print(sysconfig.get_path("platlib")) if m else print("/usr/lib/python3/dist-packages");')"
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
24 changes: 3 additions & 21 deletions src/m4/ax_python_devel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -188,31 +188,19 @@ variable to configure. See ``configure --help'' for reference.
if test $ax_python_devel_found = yes; then
#
# Check if you have distutils, else fail
# 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".
ax_python_devel_found=no
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
Expand All @@ -228,12 +216,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 c8103d0

Please sign in to comment.