-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate and remove distutils #85454
Comments
Setuptools has adopted distutils as outlined in pypa/packaging-problems#127. Although there are some straggling issues, the current release of Setuptools fully obviates distutils if a certain environment variable is set. Soon, that behavior will be default. Additionally, the distutils codebase remains maintained at pypa/distutils in a form suitable for releasing as a third-party package, should the need arise (i.e. pip install distutils). The plan now is to freeze, deprecate, and in Python N + 0.1, remove distutils. Already, Setuptools is identifying emergent bugs and other defects in distutils and providing fixes for them (bpo-41207, pypa/setuptools#2212). Keeping these changes in sync across three repos and different supported versions is tedious, so I'd like to move forward with the deprecation process as soon as possible. |
Łukasz, would it be possible to add the deprecation warning and documented deprecation to Python 3.9? |
So what is the plan to continue to support building cpython itself which depends on Distutils? Currently the build bootstraps itself without the aid of an existing Python interpreter instance. There would also be major impacts across the whole cpython development process. For example, there are many open Distutils issues in the bugs.python.org bug tracker. We need a plan on how those are to be handled (and that should take into account the expected transition from b.p.o to GitHub issues). People will continue to submit issues agains Distutils there so triage team members and core developers need to know how to handle such issues. What if an issue applies also or only to a previous release branch (i.e. where Distutils is still in the repo)? What about Distutils documentation in the Python docset? THose are just some off the top of my head. I don't think any of these issues are necessarily blockers but they need to be planned for and reviewed. I think a PEP is definitely in order for a change of this magnitude. |
It's too late to add a new deprecation in the Python 3.9 cycle. Next week is the *last* beta release. Most beta testing already took place. |
My understanding was that the plan was to move the standard library distutils into a private module somewhere in the standard library and presumably to slim it down to only the bare minimum required for what is necessary to build Python itself. We're really only concerned with the use of distutils to build packages.
As far as I can tell we've already been telling people that issues in distutils should be fixed in setuptools instead for a few years. I don't think anything needs to be done about the currently open distutils tickets before we *deprecate* distutils, though during the deprecation period we'll probably want to decide whether we want to migrate them, do a mass closure or just leave them to be ad hoc closed as people stumble upon them later. Mass closure may be complicated because tickets affecting CPython itself will still need to be addressed.
The distutils documentation is already basically just a warning page that says "stop using distutils": https://docs.python.org/3/library/distutils.html#module-distutils Before these reference materials are removed from the docs we'll need to make sure that all the stuff that's still supported is documented on the setuptools side.
A PEP may be a good idea, but I do think the change doesn't have a particularly large magnitude. Anyone using setuptools or pip has already been getting setuptools' monkey-patched version of distutils for ages now, and soon they will be getting setuptools' vendored version. The documentation already indicates that distutils is at least soft-deprecated in favor of setuptools and we've already been directing issues and PRs to setuptools instead of distutils. This last piece is really formalizing something we've been incrementally working towards for a long time now. Doesn't mean we shouldn't do it carefully and with a lot of notice, but it's also not a sudden and massive shift. |
Deprecating in 3.10 is fine - everyone who needs to know about it releases whenever they like anyway, so we just need to make _some_ announcement. I'd propose either moving it to Tools/distutils, or renaming it to _distutils. The point is that we're saying it's only fit for use for the core build now, and nobody else should ever import it (or complain about it ;) ). |
Maybe it would make sense to remove distutils from the name completely, _buildutils or something. Dunno, seems like it might be reasonable just to further separate it from the concept of "distutils" the public library. |
FYI PEP-387 (which I expect will be accepted once I catch up from vacation) specified deprecations are to be public for two releases before removal or approval from the SC for a shorter cycle. So if distutils is deprecated in 3.10 then it can be removed in 3.12 or you can ask the SC for an exemption to do it in 3.11. |
Please can we add a note in 3.9, that it will be deprecated in 3.10? |
Renaming distutils to _buildutils only delays the problem to remove it. But yes, it explicitly makes it explicit that code needs to be changed. I would like to see that neither distutils or _buildutils is installed by default, and only is available internally for building the extensions of CPython. The "old" build system to build builtins instead of extensions is still functional, so it should be ok to build the extensions also with the old build system. That would require moving all the config stuff in setup.py to autoconf tests, which is perfectly doable. The MacOS and Windows builds would need some attention too, but afaicr when asking Ned Deily and Steve Dower at the language summits, they didn't have a concern about this approach. |
+1 I would like to propose three changes:
For (3) we have to move some checks into autoconf and maybe extend Modules/Setup to support conditional compilation. |
I don't think it's a good idea to replace bad habits from distutils with bad habits in setuptools._distutils. And this is exactly what you get with pointing directly to setuptools. While splitting out distutils to a separate package in a Linux distro, I found some creative usages at runtime of a package (see my lightning talk at the language summit 2018, and [1]). From my point of view, CPython should provide documentation how to forward-port these issues without using setuptools._distutils. Currently setuptools only has one component (pkg_resources, [2]) which is used at runtime. I dislike it if more than that is used at runtime of a package. [1] https://mail.python.org/archives/list/distutils-sig@python.org/thread/74WZ7D3ARF7B3N6MAV2JBV3DW6TRHFIV/ |
The Windows build doesn't depend on distutils at all. We've had dedicated build scripts for each module since before I started contributing. |
The Windows build system didn't use setu.py even before I upgrade the VS build system to VS 2010. |
These are two different questions. We're not asking people to migrate to
At this point, the extent of CPython's documentation on this should probably be, "We are removing
I don't think anyone is planning to recommend the use of any |
Oops, just realized my previous post said |
I noticed that a new PEP draft [1] about deprecating distutils is uploaded. The current version [2] proposes to deprecate distutils in 3.10 and 3.11 and remove distutils in 3.12. [1] https://www.python.org/dev/peps/pep-0632/ |
That PR is just to add the import warning and update docs. I want to make sure that's in asap so we don't miss the release. Is there anywhere else in the docs that needs a note? Distutils has been marked as deprecated for years already, so it's really just emphasising that and adding the 3.12 removal date. I think whatsnew, library and the old doc sections is enough, yeah? |
Everyone probably noticed, but I closed all the other distutils-tagged issues (as stated in the PEP), so now this is the only one left. Anything new that is opened that relates to distutils either needs to be a release blocker (very unlikely), or closed and directed to setuptools instead. |
I have created below issues where deprecation warning is emitted due to distutils usage in tests. Probably there are other places that need an update to setuptools like setup.py used by make that emits deprecation warning during building cpython. https://bugs.python.org/issue43426 rg '(from|import) distutils' | rg -v 'Lib/distutils|rst' |
Branches and PRs are cheap, just make a new PR. The closed one is a record of one proposed change that was not taken. |
We like to remove distutils completely. However we are not there yet. There are still some test cases and tools that have to be ported to virtual environments with setuptools or use different approaches. From the top of my head |
@arhadthedev If you like to help, then you could start with updating our documentation. You could update the "distributing" section to refer to setuptools and PyPA packaging instead of distutils. There are also references to :mod:`distutils` and various functions in the distutils namespace in the whatsnew. They have to be replaced by ``distutils``, too. |
Most places now refer to setuptools or link to setuptools documentation. Some examples like zipapp need to be updated later.
Most places now refer to setuptools or link to setuptools documentation. Some examples like zipapp need to be updated later.
Extract the wheel from ensurepip's bundle and inject setuptools and distutils into sys.path.
Using setuptools on a newly built Python is not the most common case (run Python from its source directory, not on an "installed" Python). It causes multiple issues in sysconfig and setuptools. Hopefully, it seems like these issues are being fixed one by one, but it still seems to be bumpy work-in-progress (sysconfig+setuptools issues come back time to time). As you wrote, it doesn't work on Windows yet. |
#95254 is a different approach. It unpacks setuptools wheel and injects it into sys.path. |
After gh-103316 vendored setuptools into |
Debian advises at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1080851 that this breaks builds of Samba, as we use distutils.sysconfig.get_python_lib. Can distutils.sysconfig be made an alias for sysconfig so that software like ours that just needs this detail doesn't get unnecessarily broken? It is very helpful for Samba to be able to build historical versions on modern operating systems, and changes like this continue to make our development process more painful. Thanks for your understanding, Andrew Bartlett |
Installing |
Related - CPython has given this namespace over to Setuptools, so it no longer has the ability to present that name without breaking migration plans for distutils in Setuptools. Currently, Setuptools does present |
please can you check, if things like python3-config can solve your issues? this is also available for some time |
make install
#26327make install
#26329make install
(GH-26329) #26336Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: