Skip to content

Commit

Permalink
build: Replace Python distutils by sysconfig
Browse files Browse the repository at this point in the history
This module has been deprecated in Python >= 3.10
(https://peps.python.org/pep-0632/).  Replace distutils.sysconfig with
sysconfig which is not quite a drop-in replacement.

This fix is incomplete as we still reference distutils in
python/setup.py.in.  However that is only used for PIP-style
distributions (make -C python sdist) which we don't really use or
recommend.

Thanks: Miro Hrončok
See-also: https://peps.python.org/pep-0632/
See-also: https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/N6ITYHLRWIDNYNXGPYG2ZHF3ZLQWZN7L/

Cherry picked from libguestfs commit 26940f64a7406761
  • Loading branch information
rwmjones committed Jan 3, 2023
1 parent a159355 commit 068ce21
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ AS_IF([test "x$enable_python" != "xno"],
AC_MSG_CHECKING([for Python include path])
if test -z "$PYTHON_CFLAGS"; then
python_path=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_python_inc ());"`
python_platpath=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
python_path=`$PYTHON -c "import sysconfig; \
print (sysconfig.get_path('include'));"`
python_platpath=`$PYTHON -c "import sysconfig; \
print (sysconfig.get_path('platinclude'));"`
if test "$python_path" = "$python_platpath"; then
PYTHON_CFLAGS=-I$python_path
else
Expand All @@ -294,16 +294,16 @@ AS_IF([test "x$enable_python" != "xno"],
PYTHON_INSTALLDIR=
AC_MSG_CHECKING([for Python site-packages path])
if test -z "$PYTHON_INSTALLDIR"; then
PYTHON_INSTALLDIR=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_python_lib(1,0));"`
PYTHON_INSTALLDIR=`$PYTHON -c "import sysconfig; \
print (sysconfig.get_path('platlib'));"`
fi
AC_MSG_RESULT([$PYTHON_INSTALLDIR])
fi
AC_MSG_CHECKING([for Python extension suffix (PEP-3149)])
if test -z "$PYTHON_EXT_SUFFIX"; then
python_ext_suffix=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_config_var('EXT_SUFFIX') or distutils.sysconfig.get_config_var('SO'))"`
python_ext_suffix=`$PYTHON -c "import sysconfig; \
print (sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SO'))"`
PYTHON_EXT_SUFFIX=$python_ext_suffix
fi
AC_MSG_RESULT([$PYTHON_EXT_SUFFIX])
Expand Down

0 comments on commit 068ce21

Please sign in to comment.