Skip to content

Commit dda42ff

Browse files
committed
Revert "Replace use of deprecated Python module distutils.sysconfig"
This reverts commit e0e567a. On various platforms, the new approach using the sysconfig module reported incorrect values for the include directory, and so any Python-related compilations failed. Revert for now and revisit later.
1 parent d143150 commit dda42ff

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

config/python.m4

+14-14
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ python_majorversion=`echo "$python_fullversion" | sed '[s/^\([0-9]*\).*/\1/]'`
3737
python_minorversion=`echo "$python_fullversion" | sed '[s/^[0-9]*\.\([0-9]*\).*/\1/]'`
3838
python_version=`echo "$python_fullversion" | sed '[s/^\([0-9]*\.[0-9]*\).*/\1/]'`
3939
# Reject unsupported Python versions as soon as practical.
40-
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 7; then
41-
AC_MSG_ERROR([Python version $python_version is too old (version 2.7 or later is required)])
40+
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 6; then
41+
AC_MSG_ERROR([Python version $python_version is too old (version 2.6 or later is required)])
4242
fi
4343
44-
AC_MSG_CHECKING([for Python sysconfig module])
45-
if "${PYTHON}" -c 'import sysconfig' 2>&AS_MESSAGE_LOG_FD
44+
AC_MSG_CHECKING([for Python distutils module])
45+
if "${PYTHON}" -c 'import distutils' 2>&AS_MESSAGE_LOG_FD
4646
then
4747
AC_MSG_RESULT(yes)
4848
else
4949
AC_MSG_RESULT(no)
50-
AC_MSG_ERROR([sysconfig module not found])
50+
AC_MSG_ERROR([distutils module not found])
5151
fi
5252
5353
AC_MSG_CHECKING([Python configuration directory])
54-
python_configdir=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LIBPL'))))"`
54+
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
5555
AC_MSG_RESULT([$python_configdir])
5656
5757
AC_MSG_CHECKING([Python include directories])
5858
python_includespec=`${PYTHON} -c "
59-
import sysconfig
60-
a = '-I' + sysconfig.get_path('include')
61-
b = '-I' + sysconfig.get_path('platinclude')
59+
import distutils.sysconfig
60+
a = '-I' + distutils.sysconfig.get_python_inc(False)
61+
b = '-I' + distutils.sysconfig.get_python_inc(True)
6262
if a == b:
6363
print(a)
6464
else:
@@ -96,8 +96,8 @@ AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
9696
[AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
9797
AC_MSG_CHECKING([how to link an embedded Python application])
9898
99-
python_libdir=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LIBDIR'))))"`
100-
python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LDLIBRARY'))))"`
99+
python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR'))))"`
100+
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
101101
102102
# If LDLIBRARY exists and has a shlib extension, use it verbatim.
103103
ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
@@ -109,11 +109,11 @@ else
109109
# Otherwise, guess the base name of the shlib.
110110
# LDVERSION was added in Python 3.2, before that use VERSION,
111111
# or failing that, $python_version from _PGAC_CHECK_PYTHON_DIRS.
112-
python_ldversion=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LDVERSION'))))"`
112+
python_ldversion=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDVERSION'))))"`
113113
if test x"${python_ldversion}" != x""; then
114114
ldlibrary="python${python_ldversion}"
115115
else
116-
python_version_var=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('VERSION'))))"`
116+
python_version_var=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('VERSION'))))"`
117117
if test x"${python_version_var}" != x""; then
118118
ldlibrary="python${python_version_var}"
119119
else
@@ -173,7 +173,7 @@ PL/Python.])
173173
fi
174174
python_libspec="-L${python_libdir} -l${ldlibrary}"
175175
176-
python_additional_libs=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
176+
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
177177
178178
AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
179179

configure

+15-15
Original file line numberDiff line numberDiff line change
@@ -10345,34 +10345,34 @@ python_majorversion=`echo "$python_fullversion" | sed 's/^\([0-9]*\).*/\1/'`
1034510345
python_minorversion=`echo "$python_fullversion" | sed 's/^[0-9]*\.\([0-9]*\).*/\1/'`
1034610346
python_version=`echo "$python_fullversion" | sed 's/^\([0-9]*\.[0-9]*\).*/\1/'`
1034710347
# Reject unsupported Python versions as soon as practical.
10348-
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 7; then
10349-
as_fn_error $? "Python version $python_version is too old (version 2.7 or later is required)" "$LINENO" 5
10348+
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 6; then
10349+
as_fn_error $? "Python version $python_version is too old (version 2.6 or later is required)" "$LINENO" 5
1035010350
fi
1035110351

10352-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python sysconfig module" >&5
10353-
$as_echo_n "checking for Python sysconfig module... " >&6; }
10354-
if "${PYTHON}" -c 'import sysconfig' 2>&5
10352+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python distutils module" >&5
10353+
$as_echo_n "checking for Python distutils module... " >&6; }
10354+
if "${PYTHON}" -c 'import distutils' 2>&5
1035510355
then
1035610356
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1035710357
$as_echo "yes" >&6; }
1035810358
else
1035910359
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1036010360
$as_echo "no" >&6; }
10361-
as_fn_error $? "sysconfig module not found" "$LINENO" 5
10361+
as_fn_error $? "distutils module not found" "$LINENO" 5
1036210362
fi
1036310363

1036410364
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python configuration directory" >&5
1036510365
$as_echo_n "checking Python configuration directory... " >&6; }
10366-
python_configdir=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LIBPL'))))"`
10366+
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
1036710367
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $python_configdir" >&5
1036810368
$as_echo "$python_configdir" >&6; }
1036910369

1037010370
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python include directories" >&5
1037110371
$as_echo_n "checking Python include directories... " >&6; }
1037210372
python_includespec=`${PYTHON} -c "
10373-
import sysconfig
10374-
a = '-I' + sysconfig.get_path('include')
10375-
b = '-I' + sysconfig.get_path('platinclude')
10373+
import distutils.sysconfig
10374+
a = '-I' + distutils.sysconfig.get_python_inc(False)
10375+
b = '-I' + distutils.sysconfig.get_python_inc(True)
1037610376
if a == b:
1037710377
print(a)
1037810378
else:
@@ -10388,8 +10388,8 @@ $as_echo "$python_includespec" >&6; }
1038810388
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link an embedded Python application" >&5
1038910389
$as_echo_n "checking how to link an embedded Python application... " >&6; }
1039010390

10391-
python_libdir=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LIBDIR'))))"`
10392-
python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LDLIBRARY'))))"`
10391+
python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR'))))"`
10392+
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
1039310393

1039410394
# If LDLIBRARY exists and has a shlib extension, use it verbatim.
1039510395
ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
@@ -10401,11 +10401,11 @@ else
1040110401
# Otherwise, guess the base name of the shlib.
1040210402
# LDVERSION was added in Python 3.2, before that use VERSION,
1040310403
# or failing that, $python_version from _PGAC_CHECK_PYTHON_DIRS.
10404-
python_ldversion=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LDVERSION'))))"`
10404+
python_ldversion=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDVERSION'))))"`
1040510405
if test x"${python_ldversion}" != x""; then
1040610406
ldlibrary="python${python_ldversion}"
1040710407
else
10408-
python_version_var=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('VERSION'))))"`
10408+
python_version_var=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('VERSION'))))"`
1040910409
if test x"${python_version_var}" != x""; then
1041010410
ldlibrary="python${python_version_var}"
1041110411
else
@@ -10465,7 +10465,7 @@ PL/Python." "$LINENO" 5
1046510465
fi
1046610466
python_libspec="-L${python_libdir} -l${ldlibrary}"
1046710467

10468-
python_additional_libs=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
10468+
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
1046910469

1047010470
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${python_libspec} ${python_additional_libs}" >&5
1047110471
$as_echo "${python_libspec} ${python_additional_libs}" >&6; }

doc/src/sgml/installation.sgml

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ su - postgres
195195
To build the <application>PL/Python</application> server programming
196196
language, you need a <productname>Python</productname>
197197
installation with the header files and
198-
the <application>sysconfig</application> module. The minimum
199-
required version is <productname>Python</productname> 2.7.
198+
the <application>distutils</application> module. The minimum
199+
required version is <productname>Python</productname> 2.6.
200200
<productname>Python 3</productname> is supported if it's
201201
version 3.1 or later; but see
202202
<xref linkend="plpython-python23"/>

0 commit comments

Comments
 (0)