Disable setuptools injection in Python 3.12+ (whenever distutils gets removed from stdlib)
See original GitHub issueWhat’s the problem this feature will solve?
Currently, pip invokes setup.py
files in a manner that injects setuptools into sys.modules
; which is mainly for compatibility with projects that use distutils.setup
in their setup.py
files.
With distutils being deprecated and slated for removal, we should drop our compatibility shim for this.
Describe the solution you’d like
Change the logic used for make_setuptools_shim_args
, to not attempt the setuptools injection for Python 3.12+ (whenever distutils
gets removed).
Alternative Solutions
Do nothing. Continue performing this injection after Python 3.12+, since it’ll be a no-op.
Additional context
https://pip.pypa.io/en/stable/cli/pip/#setuptools-injection for the current documentation on this.
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Results From Across the Web
PEP 632 – Deprecate distutils module
Pip has been silently replacing distutils with setuptools when installing packages for a long time ... It is time to remove it from...
Read more >distutils — Building and installing Python modules — Python ...
distutils is deprecated with removal planned for Python 3.12. ... The distutils package provides support for building and installing additional modules in.
Read more >PEP 632 - Deprecate distutils module
I think this argument is going a bit in the wrong direction. “setup.py install” is no longer needed nowadays, since pip, ...
Read more >Issue 41282: Deprecate and remove distutils - Python tracker
Already, Setuptools is identifying emergent bugs and other defects in ... deprecate distutils in 3.10 and 3.11 and remove distutils in 3.12.
Read more >What's new in PyObjC — PyObjC - the Python to Objective-C ...
Added two options to the build_ext command in the setup.py of pyobjc-core: ... Remove -[OC_PythonArray getObjects:inRange:] , it is not part of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The 3.12 schedule isn’t published yet, but looking at the 3.11 schedule, I’d expect 3.12beta1 to be some time around May 2023.
Note that while distutils is scheduled for removal in 3.12, it is not guaranteed to be, and if we remove the shim without Python actually removing the module, the bare
distutils.core.setup()
call would do more harm than we keep the legacy path. So the removal should not happen before distutils is actually gone (i.e. weit until 3.12beta1 or so).