Teach configure --with-python to report the Python version number.
We already do this for Perl and some other interesting tools, so it seems sensible to do it for Python as well, especially since the sub-release number is never determinable from other configure output and even the major/minor numbers may not be clear without excavation in config.log. While at it, get rid of the code's assumption that both the major and minor numbers contain exactly one digit. That will foreseeably be broken by Python 3.10 in perhaps four or five years. That's far enough out that we probably don't need to back-patch this. Discussion: https://postgr.es/m/2186.1522681145@sss.pgh.pa.us
This commit is contained in:
parent
2764d5dcfa
commit
beff4bb9c7
@ -22,6 +22,17 @@ fi
|
||||
# as well as the Python version.
|
||||
AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
|
||||
[AC_REQUIRE([PGAC_PATH_PYTHON])
|
||||
python_fullversion=`${PYTHON} -c "import sys; print(sys.version)" | sed q`
|
||||
AC_MSG_NOTICE([using python $python_fullversion])
|
||||
# python_fullversion is typically n.n.n plus some trailing junk
|
||||
python_majorversion=`echo "$python_fullversion" | sed '[s/^\([0-9]*\).*/\1/]'`
|
||||
python_minorversion=`echo "$python_fullversion" | sed '[s/^[0-9]*\.\([0-9]*\).*/\1/]'`
|
||||
python_version=`echo "$python_fullversion" | sed '[s/^\([0-9]*\.[0-9]*\).*/\1/]'`
|
||||
# Reject unsupported Python versions as soon as practical.
|
||||
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
|
||||
AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for Python distutils module])
|
||||
if "${PYTHON}" -c 'import distutils' 2>&AS_MESSAGE_LOG_FD
|
||||
then
|
||||
@ -30,18 +41,11 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([distutils module not found])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([Python configuration directory])
|
||||
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
|
||||
python_minorversion=`${PYTHON} -c "import sys; print(sys.version[[2]])"`
|
||||
python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
|
||||
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
|
||||
AC_MSG_RESULT([$python_configdir])
|
||||
|
||||
# Reject unsupported Python versions as soon as practical.
|
||||
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
|
||||
AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([Python include directories])
|
||||
python_includespec=`${PYTHON} -c "
|
||||
import distutils.sysconfig
|
||||
|
21
configure
vendored
21
configure
vendored
@ -9516,6 +9516,18 @@ if test x"$PYTHON" = x""; then
|
||||
fi
|
||||
|
||||
|
||||
python_fullversion=`${PYTHON} -c "import sys; print(sys.version)" | sed q`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: using python $python_fullversion" >&5
|
||||
$as_echo "$as_me: using python $python_fullversion" >&6;}
|
||||
# python_fullversion is typically n.n.n plus some trailing junk
|
||||
python_majorversion=`echo "$python_fullversion" | sed 's/^\([0-9]*\).*/\1/'`
|
||||
python_minorversion=`echo "$python_fullversion" | sed 's/^[0-9]*\.\([0-9]*\).*/\1/'`
|
||||
python_version=`echo "$python_fullversion" | sed 's/^\([0-9]*\.[0-9]*\).*/\1/'`
|
||||
# Reject unsupported Python versions as soon as practical.
|
||||
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
|
||||
as_fn_error $? "Python version $python_version is too old (version 2.4 or later is required)" "$LINENO" 5
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python distutils module" >&5
|
||||
$as_echo_n "checking for Python distutils module... " >&6; }
|
||||
if "${PYTHON}" -c 'import distutils' 2>&5
|
||||
@ -9527,20 +9539,13 @@ else
|
||||
$as_echo "no" >&6; }
|
||||
as_fn_error $? "distutils module not found" "$LINENO" 5
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python configuration directory" >&5
|
||||
$as_echo_n "checking Python configuration directory... " >&6; }
|
||||
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[0])"`
|
||||
python_minorversion=`${PYTHON} -c "import sys; print(sys.version[2])"`
|
||||
python_version=`${PYTHON} -c "import sys; print(sys.version[:3])"`
|
||||
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $python_configdir" >&5
|
||||
$as_echo "$python_configdir" >&6; }
|
||||
|
||||
# Reject unsupported Python versions as soon as practical.
|
||||
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
|
||||
as_fn_error $? "Python version $python_version is too old (version 2.4 or later is required)" "$LINENO" 5
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python include directories" >&5
|
||||
$as_echo_n "checking Python include directories... " >&6; }
|
||||
python_includespec=`${PYTHON} -c "
|
||||
|
Loading…
x
Reference in New Issue
Block a user