Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbeff4bb

Browse files
committed
Teach configure --with-python to report the Python version number.
We already do this for Perl and some other interesting tools, so itseems sensible to do it for Python as well, especially since thesub-release number is never determinable from other configure outputand even the major/minor numbers may not be clear without excavationin config.log.While at it, get rid of the code's assumption that both the major andminor numbers contain exactly one digit. That will foreseeably bebroken by Python 3.10 in perhaps four or five years. That's far enoughout that we probably don't need to back-patch this.Discussion:https://postgr.es/m/2186.1522681145@sss.pgh.pa.us
1 parent2764d5d commitbeff4bb

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

‎config/python.m4

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ fi
2222
# as well as the Python version.
2323
AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
2424
[AC_REQUIRE([PGAC_PATH_PYTHON])
25+
python_fullversion=`${PYTHON} -c "import sys; print(sys.version)" | sed q`
26+
AC_MSG_NOTICE([using python $python_fullversion])
27+
# python_fullversion is typically n.n.n plus some trailing junk
28+
python_majorversion=`echo "$python_fullversion" | sed '[s/^\([0-9]*\).*/\1/]'`
29+
python_minorversion=`echo "$python_fullversion" | sed '[s/^[0-9]*\.\([0-9]*\).*/\1/]'`
30+
python_version=`echo "$python_fullversion" | sed '[s/^\([0-9]*\.[0-9]*\).*/\1/]'`
31+
# Reject unsupported Python versions as soon as practical.
32+
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
33+
AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
34+
fi
35+
2536
AC_MSG_CHECKING([for Python distutils module])
2637
if "${PYTHON}" -c 'import distutils' 2>&AS_MESSAGE_LOG_FD
2738
then
@@ -30,18 +41,11 @@ else
3041
AC_MSG_RESULT(no)
3142
AC_MSG_ERROR([distutils module not found])
3243
fi
44+
3345
AC_MSG_CHECKING([Python configuration directory])
34-
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
35-
python_minorversion=`${PYTHON} -c "import sys; print(sys.version[[2]])"`
36-
python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
3746
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
3847
AC_MSG_RESULT([$python_configdir])
3948
40-
# Reject unsupported Python versions as soon as practical.
41-
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
42-
AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
43-
fi
44-
4549
AC_MSG_CHECKING([Python include directories])
4650
python_includespec=`${PYTHON} -c "
4751
import distutils.sysconfig

‎configure

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9516,6 +9516,18 @@ if test x"$PYTHON" = x""; then
95169516
fi
95179517

95189518

9519+
python_fullversion=`${PYTHON} -c "import sys; print(sys.version)" | sed q`
9520+
{ $as_echo "$as_me:${as_lineno-$LINENO}: using python $python_fullversion" >&5
9521+
$as_echo "$as_me: using python $python_fullversion" >&6;}
9522+
# python_fullversion is typically n.n.n plus some trailing junk
9523+
python_majorversion=`echo "$python_fullversion" | sed 's/^\([0-9]*\).*/\1/'`
9524+
python_minorversion=`echo "$python_fullversion" | sed 's/^[0-9]*\.\([0-9]*\).*/\1/'`
9525+
python_version=`echo "$python_fullversion" | sed 's/^\([0-9]*\.[0-9]*\).*/\1/'`
9526+
# Reject unsupported Python versions as soon as practical.
9527+
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
9528+
as_fn_error $? "Python version $python_version is too old (version 2.4 or later is required)" "$LINENO" 5
9529+
fi
9530+
95199531
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python distutils module" >&5
95209532
$as_echo_n "checking for Python distutils module... " >&6; }
95219533
if "${PYTHON}" -c 'import distutils' 2>&5
@@ -9527,20 +9539,13 @@ else
95279539
$as_echo "no" >&6; }
95289540
as_fn_error $? "distutils module not found" "$LINENO" 5
95299541
fi
9542+
95309543
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python configuration directory" >&5
95319544
$as_echo_n "checking Python configuration directory... " >&6; }
9532-
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[0])"`
9533-
python_minorversion=`${PYTHON} -c "import sys; print(sys.version[2])"`
9534-
python_version=`${PYTHON} -c "import sys; print(sys.version[:3])"`
95359545
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
95369546
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $python_configdir" >&5
95379547
$as_echo "$python_configdir" >&6; }
95389548

9539-
# Reject unsupported Python versions as soon as practical.
9540-
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
9541-
as_fn_error $? "Python version $python_version is too old (version 2.4 or later is required)" "$LINENO" 5
9542-
fi
9543-
95449549
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python include directories" >&5
95459550
$as_echo_n "checking Python include directories... " >&6; }
95469551
python_includespec=`${PYTHON} -c "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp