Although distutils_hack is deprecated (#4137), there are still consumers that rely on the presence of distutils or access to its internals to conduct some business (see the distutils deprecation tag).
One aspect of this deprecation is to make the compilers module independent. Some work has been done on that by moving the compilers into distutils.compilers with the intention of eventually releasing that functionality as a third-party compliers.C package. Before that can happen, those modules need to be decoupled from distutils (and any interaction with distutils made a formal interface). There is some work already drafted (and even some merged) in https://github.com/pypa/distutils/tree/debt/compilers-deps.
Let's finish the work. Let's provide solutions for each of the distutils deprecation issues and decouple the compilers functionality. Some backward incompatibility may be acceptable, but we'll aim to remain compatible where feasible.
Plan
End-state: compilers.C fully decoupled from distutils and extractable as a standalone distribution under jaraco/compilers.C. compilers stays a namespace package so future compilers.<lang> siblings can be added. Removal of the top-level distutils hack is gated on these replacements shipping.
The work is broken into the sub-issues tracked above. Grouped into phases:
Phase 1 — Decouple compilers.C from distutils internals (pypa/distutils)
Phase 2 — Public API (pypa/distutils)
Phase 3 — Migration docs (pypa/setuptools)
Phase 4 — Retire the hack (pypa/setuptools; gated on Phases 1–3)
Extraction
Design decisions: the standalone library defaults to stdlib sysconfig (behavior change acceptable), with a possibly-deprecated shim for distutils/setuptools to inject specialized behavior; no setuptools re-export layer — consumers import from the compilers package directly.
Although distutils_hack is deprecated (#4137), there are still consumers that rely on the presence of distutils or access to its internals to conduct some business (see the distutils deprecation tag).
One aspect of this deprecation is to make the compilers module independent. Some work has been done on that by moving the compilers into
distutils.compilerswith the intention of eventually releasing that functionality as a third-partycompliers.Cpackage. Before that can happen, those modules need to be decoupled from distutils (and any interaction with distutils made a formal interface). There is some work already drafted (and even some merged) in https://github.com/pypa/distutils/tree/debt/compilers-deps.Let's finish the work. Let's provide solutions for each of the distutils deprecation issues and decouple the compilers functionality. Some backward incompatibility may be acceptable, but we'll aim to remain compatible where feasible.
Plan
End-state:
compilers.Cfully decoupled from distutils and extractable as a standalone distribution underjaraco/compilers.C.compilersstays a namespace package so futurecompilers.<lang>siblings can be added. Removal of the top-leveldistutilshack is gated on these replacements shipping.The work is broken into the sub-issues tracked above. Grouped into phases:
Phase 1 — Decouple
compilers.Cfrom distutils internals (pypa/distutils)-Ooptimization flag under-m32#5265 — Fix mingw bare-Ounder-m32(closes mingw64 win32 compilation issue - does not accept "-O" #4873)compilers.C(dropdistutils._log) #5266 — Inline logging (dropdistutils._log)compilers.C#5267 — Vendor small build/filesystem helperscompilers.C#5268 — Replace version & platform-compat shimscompilers.Cto stdlibsysconfig+ injection shim (investigation) #5269 — Move to stdlibsysconfig+ injection shim (investigation)compilers.errors#5270 — Consolidate compiler exceptions atcompilers.errorsPhase 2 — Public API (pypa/distutils)
compilers.C#5271 — Public API forcompilers.C(resolves Expose compiler classes for customized use #2806, Equivalent for distutils.ccompiler.new_compiler needed #4540)Phase 3 — Migration docs (pypa/setuptools)
Phase 4 — Retire the hack (pypa/setuptools; gated on Phases 1–3)
distutilsinjection) #5273 — Retire the distutils hack (see also Deprecate SETUPTOOLS_USE_DISTUTILS=stdlib #3625, Deprecate usage of import distutils except internal to Setuptools #3622)Extraction
jaraco/compilers.Cdistribution #5274 — Stand up standalonejaraco/compilers.CdistributionDesign decisions: the standalone library defaults to stdlib
sysconfig(behavior change acceptable), with a possibly-deprecated shim for distutils/setuptools to inject specialized behavior; no setuptools re-export layer — consumers import from thecompilerspackage directly.