Skip to content

Commit

Permalink
Remove remaining use of deprecated distutils.
Browse files Browse the repository at this point in the history
Addresses #1080668
  • Loading branch information
andypugh committed Oct 7, 2024
1 parent ffbadb4 commit 7cb74c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
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; print(sysconfig.get_path("platlib"))'`
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.sysconfig.get_path("include"))"`
if test x$ax_python_header != x; then
break;
fi
Expand Down
27 changes: 2 additions & 25 deletions src/m4/ax_python_devel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,18 @@ variable to configure. See ``configure --help'' for reference.
fi
#
# 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_ERROR([cannot import Python module "distutils".
AC_MSG_ERROR([cannot import Python module "sysconfig".
Please check your Python installation. The error was:
$ac_sysconfig_result])
PYTHON_VERSION=""
fi
fi
#
Expand All @@ -167,12 +158,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 Expand Up @@ -273,10 +258,6 @@ EOD`
if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_path('purelib'));"`
else
# distutils.sysconfig way
PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_python_lib(0,0));"`
fi
fi
AC_MSG_RESULT([$PYTHON_SITE_PKG])
Expand All @@ -290,10 +271,6 @@ EOD`
if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_path('platlib'));"`
else
# distutils.sysconfig way
PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
print (sysconfig.get_python_lib(1,0));"`
fi
fi
AC_MSG_RESULT([$PYTHON_PLATFORM_SITE_PKG])
Expand Down

0 comments on commit 7cb74c9

Please sign in to comment.