I removed many deprecated functions of the Python API and C API in Python 3.12. I prefer to do it as soon as possible at the beginning of the Python 3.12 release cycle. This way, we can collect more feedback and earlier, have more time to update affected projects, and also have more time to decide if some changes should be reverted or not. See What’s New In Python 3.12 — Python 3.12.0a1 documentation for all changes. Examples:
Remove the infamous distutils package: install setuptools to get setuptools’ favor of distutils (and enjoy subtle differences with the removed flavor!)
Remove ssl.wrap_socket(): use ssl.SSLContext.wrap_socket() instead, it’s more secure.
"\d", "\477" and other invalid escape sequence now emit SyntaxWarning instead of DeprecationWarning. Run pycodestyle --select W605 $(find project/ -name "*.py") to find affected strings of your project/ directory.
I created this thread to collaborate on handling Python 3.12 incompatible changes. If you are affected or if you want to help, you’re welcome here! If you dislike these changes, that’s also the right place to give your feedback.
If setuptools 60 or newer is installed, distutils is provided by setuptools. It’s the setuptools/_distutils/ module. Example:
$ /opt/py312/bin/python3
Python 3.12.0a1+ (heads/main:f09da28768, Nov 4 2022, 17:46:22) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>> distutils
<module 'distutils' (/opt/py312/lib/python3.12/site-packages/setuptools/_distutils/__init__.py)>
It is made possible thanks to distutils-precedence.pth file installed by setuptools.
There is a bug on Python 3.12 (without distutils): if pip is imported first, import setuptools and import distutils fails since _distutils_hack looks for the stdlib distutils instead. I reported the bug #3661 to setuptools.