Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nADiC-0005cJ-VC for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jan 2022 16:21:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nADiA-0003YW-On for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jan 2022 16:21:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nADiA-0003YM-Ey for pgsql-hackers@lists.postgresql.org; Wed, 19 Jan 2022 16:21:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nADi5-0002ll-Op for pgsql-hackers@lists.postgresql.org; Wed, 19 Jan 2022 16:21:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20JGLFQu528425; Wed, 19 Jan 2022 11:21:15 -0500 From: Tom Lane To: Peter Eisentraut cc: Andrew Dunstan , pgsql-hackers@lists.postgresql.org Subject: Re: Replace uses of deprecated Python module distutils.sysconfig In-reply-to: <426613.1642551491@sss.pgh.pa.us> References: <0cd3579e-7790-aa05-0202-c6ce14d0af73@enterprisedb.com> <3777643.1639056683@sss.pgh.pa.us> <312939.1642519464@sss.pgh.pa.us> <7129af76-acf6-f4d5-0de6-a479f75d8ad7@enterprisedb.com> <322779.1642525461@sss.pgh.pa.us> <426613.1642551491@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 18 Jan 2022 19:18:11 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <528397.1642609266.0@sss.pgh.pa.us> Date: Wed, 19 Jan 2022 11:21:15 -0500 Message-ID: <528424.1642609275@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <528397.1642609266.1@sss.pgh.pa.us> I wrote: > Anyway, based on these results, we might have better luck switching to > sysconfig after we start forcing python3. On the other hand, that answer is not back-patchable, and we surely need a back-patchable fix, because people will try to build the back branches against newer pythons. Based on the buildfarm results so far, the problem can be described as "some installations say /usr/local when they should have said /usr". I experimented with the attached delta patch and it fixes the problem on my Debian 9 image. (I don't know Python, so there may be a better way to do this.) We'd have to also bump the minimum 3.x version to 3.2, but that seems very unlikely to bother anyone. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="hack-bad-sysconfig-answer.patch"; charset="us-ascii" Content-ID: <528397.1642609266.2@sss.pgh.pa.us> Content-Description: hack-bad-sysconfig-answer.patch Content-Transfer-Encoding: quoted-printable diff --git a/config/python.m4 b/config/python.m4 index 8ca1eaa64b..c65356c6ac 100644 --- a/config/python.m4 +++ b/config/python.m4 @@ -56,13 +56,20 @@ AC_MSG_RESULT([$python_configdir]) = AC_MSG_CHECKING([Python include directories]) python_includespec=3D`${PYTHON} -c " -import sysconfig -a =3D '-I' + sysconfig.get_path('include') -b =3D '-I' + sysconfig.get_path('platinclude') +import sysconfig, os.path +a =3D sysconfig.get_path('include') +b =3D sysconfig.get_path('platinclude') +# Some versions of sysconfig report '/usr/local/include' +# when they should have said '/usr/include' +if not os.path.exists(a + '/Python.h'): + aalt =3D a.replace('/usr/local/', '/usr/', 1) + if os.path.exists(aalt + '/Python.h'): + a =3D aalt + b =3D b.replace('/usr/local/', '/usr/', 1) if a =3D=3D b: - print(a) + print('-I' + a) else: - print(a + ' ' + b)"` + print('-I' + a + ' -I' + b)"` if test "$PORTNAME" =3D win32 ; then python_includespec=3D`echo $python_includespec | sed 's,[[\]],/,g'` fi diff --git a/configure b/configure index 9c856cb1d5..f88db9467d 100755 --- a/configure +++ b/configure @@ -10370,13 +10370,20 @@ $as_echo "$python_configdir" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python include director= ies" >&5 $as_echo_n "checking Python include directories... " >&6; } python_includespec=3D`${PYTHON} -c " -import sysconfig -a =3D '-I' + sysconfig.get_path('include') -b =3D '-I' + sysconfig.get_path('platinclude') +import sysconfig, os.path +a =3D sysconfig.get_path('include') +b =3D sysconfig.get_path('platinclude') +# Some versions of sysconfig report '/usr/local/include' +# when they should have said '/usr/include' +if not os.path.exists(a + '/Python.h'): + aalt =3D a.replace('/usr/local/', '/usr/', 1) + if os.path.exists(aalt + '/Python.h'): + a =3D aalt + b =3D b.replace('/usr/local/', '/usr/', 1) if a =3D=3D b: - print(a) + print('-I' + a) else: - print(a + ' ' + b)"` + print('-I' + a + ' -I' + b)"` if test "$PORTNAME" =3D win32 ; then python_includespec=3D`echo $python_includespec | sed 's,[\],/,g'` fi ------- =_aaaaaaaaaa0--