Replace uses of deprecated Python module distutils.sysconfig

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Replace uses of deprecated Python module distutils.sysconfig
Date: 2021-12-02 07:20:48
Message-ID: c74add3c-09c4-a9dd-1a03-a846e5b2fc52@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

With Python 3.10, configure spits out warnings about the module
distutils.sysconfig being deprecated and scheduled for removal in Python
3.12:

<string>:1: DeprecationWarning: The distutils.sysconfig module is
deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and
slated for removal in Python 3.12. Use setuptools or check PEP 632 for
potential alternatives

This patch changes the uses in configure to use the module sysconfig
instead. The logic stays the same. (It's basically the same module but
as its own top-level module.)

Note that sysconfig exists since Python 2.7, so this moves the minimum
required version up from Python 2.6.

Buildfarm impact:

gaur and prariedog use Python 2.6 and would need to be upgraded.

Possible backpatching:

Backpatching should be considered, since surely someone will otherwise
complain when Python 3.12 comes around. But dropping support for Python
versions in stable branches should be done with some care.

Python 3.10 was released Oct. 4, 2021, so it is quite new. Python major
releases are now yearly, so the above-mentioned Python 3.12 can be
expected in autumn of 2023.

Current PostgreSQL releases support Python versions as follows:

PG10: 2.4+
PG11: 2.4+
PG12: 2.4+ (EOL Nov. 2024)
PG13: 2.6+
PG14: 2.6+

So unfortunately, we won't be able to EOL all versions with Python 2.4
support before Python 3.12 arrives.

I suggest leaving the backbranches alone for now. At the moment, we
don't even know whether additional changes will be required for 3.12
(and 3.11) support, so the overall impact isn't known yet. In a few
months, we will probably know more about this.

In the meantime, the warnings can be silenced using

export PYTHONWARNINGS='ignore::DeprecationWarning'

(It ought to be possible to be more specific, like
'ignore::DeprecationWarning:distutils.sysconfig', but it doesn't seem to
work for me.)

(I don't recommend putting that into configure, since then we wouldn't
be able to learn about issues like this.)

Attachment Content-Type Size
0001-Replace-uses-of-deprecated-Python-module-distutils.s.patch text/plain 10.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2021-12-02 07:30:36 snowball update
Previous Message Peter Smith 2021-12-02 07:18:14 Re: row filtering for logical replication