On Tue, May 10, 2022 at 12:59 AM Victor Stinner <vstin...@python.org> wrote:

> Hi,
>
> Two years ago, PEP 632 "Deprecate distutils module" was accepted: the
> distutils package was deprecated in Python 3.10 and scheduled for
> removal in Python 3.12. Questions.
>
> * Is the Python ecosystem ready for the distutils removal? How many
> projects are expected to be broken by this removal?
>
> * Is setuptools a drop-in replacement of distutils for most cases? Are
> there tools and documentation explaining how to replace distutils with
> setuptools?
>

Change `import distutils` with `import setuptools`. 😉 But more thorough
guidance can be found at
https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html?highlight=distutils
.


>
> * Is there a tool to migrate from setup.py (distutils) to
> pyproject.toml (setuptools)? The dephell project can convert a
> setup.py script to pyproject.toml using poetry as the build system.
>

You don't have to migrate a setuptools project to pyproject.toml to keep
functioning. I would strongly encourage people at least specify a
build-system table in pyproject.toml as it's easy to do, but pip doesn't
require even this for setuptools projects:

```toml

[build-system]requires = ["setuptools"]build-backend = "setuptools.build_meta"

```

But the rest of the project's metadata can stay in setup.py or setup.cfg if
they want. But there is experimental support to fully support PEP 621 and
specifying metadata in pyproject.toml:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html .


>
> * Can we simply suggest installing setuptools to users who still use
> "import distutils"? setuptools now provides the a "distutils" package.
>

If they are unwilling to update, yes.


>
> * Should we keep distutils in Python stdlib a few more Python releases
> if the removal causes too many practical issues?
>

I don't think so.

-Brett


>
>
> A code search in top 5000 PyPI projects (at 2022-01-26) using the
> regex '(import|from) distutils' matchs 5,567 lines in 1,229 projects.
> Some statistics:
>
> * 851 projects (1,372 lines) import distutils in setup.py
> * 233 projects (700 lines) use distutils.version
> * 92 projects (205 lines) use distutils.util
> * 1,018 lines are type annotations (.pyi files)
>
> I failed to group the remaining 2,272 lines.
>
> Converting 851 projects from setup.py with distutils to pyproject.toml
> is going to take a few months if not years. Python 3.12 will likely be
> released in October 2023 (in year and a half).
>
>
> Since setuptools 60 (December 2021), setuptools installs a
> distutils-precedence.pth file to override the stdlib module with its
> local distutils copy by default. The SETUPTOOLS_USE_DISTUTILS=stdlib
> environment variable can be used to explicitly request the stdlib
> flavor. If I understood correct, distutils is now maintained in
> setuptools, rather than in the Python stdlib.
>
> Python "make install" installs an up to date setuptools and so
> indirectly its distutils-precedence.pth file which makes the distutils
> local copy of setuptools available. But many Linux distributions
> splits setuptools and pip from the "python" package.
>
>
> Right now, Python still uses distutils internally for multiple use
> cases. I propose to start with renaming the distutils package to
> _distutils in the stdlib:
>
> * https://github.com/python/cpython/issues/92584
> * https://github.com/python/cpython/pull/92585
>
> Right now, the change is blocked by pip which still imports distutils
> (even if it prefers sysconfig in practice on Python 3.10 and newer). I
> reported the issue to pip, it should be easy to fix.
>
> Once Python will no longer depend on _distutils, it will be possible
> to fully remove it.
>
>
> By the way, Fedora 35 now longer provides automatically setuptools
> when building a Python package. A dependency to setuptools must now be
> explicit, since they are projects which don't use setuptools nor
> distutils, but other build systems.
>
>
> https://fedoraproject.org/wiki/Changes/Reduce_dependencies_on_python3-setuptools
>
> Victor
> --
> Night gathers, and now my watch begins. It shall not end until my death.
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/XFZJ43VSIWCYNQ5ZYT64XF7PMH4YDUWC/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/7YOD2KW3JND5DDHOBS22XVCUYQWWTEP7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to