From 4e5ce3c1aeadf81b504bc9d683b67950bd3f8766 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue, 21 Feb 2017 11:28:23 -0500
Subject: [PATCH] Reject too-old Python versions a bit sooner.

Commit 04aad4018 added this check after the search for a Python shared
library, which seems to me to be a pretty unfriendly ordering.  The
search might fail for what are basically version-related reasons, and
in such a case it'd be better to say "your Python is too old" than
"could not find shared library for Python".
---
 config/python.m4 | 8 +++++++-
 configure        | 8 +++++---
 configure.in     | 3 ---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/config/python.m4 b/config/python.m4
index 7f775e77d23..953d7093053 100644
--- a/config/python.m4
+++ b/config/python.m4
@@ -18,7 +18,8 @@ fi
 
 # _PGAC_CHECK_PYTHON_DIRS
 # -----------------------
-# Determine the name of various directories of a given Python installation.
+# Determine the name of various directories of a given Python installation,
+# as well as the Python version.
 AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
 [AC_REQUIRE([PGAC_PATH_PYTHON])
 AC_MSG_CHECKING([for Python distutils module])
@@ -36,6 +37,11 @@ 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
diff --git a/configure b/configure
index 908109849e6..6a8db7ce2c8 100755
--- a/configure
+++ b/configure
@@ -7594,6 +7594,11 @@ python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filte
 { $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 "
@@ -7699,9 +7704,6 @@ $as_echo "${python_libspec} ${python_additional_libs}" >&6; }
 
 
 
-  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
 fi
 
 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
diff --git a/configure.in b/configure.in
index 9e4fb0fa80a..01b618c931d 100644
--- a/configure.in
+++ b/configure.in
@@ -927,9 +927,6 @@ fi
 if test "$with_python" = yes; then
   PGAC_PATH_PYTHON
   PGAC_CHECK_PYTHON_EMBED_SETUP
-  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
 fi
 
 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
-- 
GitLab