# Adding the old \`distutils.ccompiler\` to the stdlib

**URL:** <https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115>\
**Category:** Ideas\
**Created:** [May 11, 2024, 6:34pm UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115 "2024-05-11T18:34:25Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [May 11, 2024, 10:31pm UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/21 "2024-05-11T22:31:15Z")

</div>

Would any of the standard libraries in question have any C components? I can’t recall any. If there are no binaries to include then it should be a simple matter of verifying the source against public record of the last maintained version.

---

<div class="post-metadata">

**Author:** ![jamestwebber](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamestwebber/32/12799_2.png) [@jamestwebber](https://discuss.python.org/u/jamestwebber)\
**Post date:** [May 11, 2024, 10:43pm UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/22 "2024-05-11T22:43:29Z")

</div>

> [@JakobStadler](#):
>
> Before we start recommending the `standard-` packages, are they vetted?

Full disclosure: I’m not vetted either. 😅

This is a reasonable concern. All I know is that the person who put them up (@youknowone) is one of the primary contributors to the [RustPython](https://github.com/RustPython/RustPython/) project, and also contributes to the [Rust python parser](https://github.com/RustPython/Parser) and `ruff`. If he’s a sleeper agent he’s in deep.

---

<div class="post-metadata">

**Author:** ![gcewing](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gcewing](https://discuss.python.org/u/gcewing)\
**Post date:** [May 12, 2024, 1:38am UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/23 "2024-05-12T01:38:35Z")

</div>

Distutils was removed because it was an evolutionary dead end – so much  
code relied on details of its internals that it was impossible to ever  
change any part of it.

The trouble is that the new packaging stuff intended to replace it only  
covers part of its functionality.

If something is to be added to the stdlib to cover the compiler  
functionality, it would be better to design something new and better  
than just pull in the old distutils.ccompiler module, since that would  
just be bringing back all the old problems.

I think it could be something very small and simple. For me the main  
benefit would be that it would know how to compile extension modules for  
the current Python installation with all the right compiler options.

---

<div class="post-metadata">

**Author:** ![youknowone](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/youknowone/32/19382_2.png) [@youknowone](https://discuss.python.org/u/youknowone)\
**Post date:** [May 12, 2024, 1:43am UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/24 "2024-05-12T01:43:03Z")

</div>

This is exactly the reason why I think python core or PyPA have to do it.

I left [a letter](https://github.com/youknowone/python-deadlib?tab=readme-ov-file#to-python-developers) to the project page.

The packages will be frozen as they distributed to prevent supply attack and the cost to review the patches. But still don’t believe me, I will not catch something goes wrong even if my account or PyPI API key is hacked.  
If you agree to the points, please ask Python core or PyPA to redistribute deprecated stdlib libraries to PyPI when they remove it.

---

<div class="post-metadata">

**Author:** ![ZeroIntensity](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zerointensity/32/10639_2.png) [@ZeroIntensity](https://discuss.python.org/u/ZeroIntensity)\
**Post date:** [May 12, 2024, 1:46am UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/25 "2024-05-12T01:46:19Z")

</div>

From what I’ve looked into, there’s nothing small about a platform-independent C compiler interface, since you pretty much have to reimplement it for every compiler you want to support. `distutils.ccompiler` is the _only_ implementation that I know of that actually did this, so you’re probably just better off using the vendored copy from `setuptools` rather than spending however much time building one yourself. If you’re going to design a new one, I doubt it will make it into the standard library – it will likely just exist on PyPI.

---

<div class="post-metadata">

**Author:** ![youknowone](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/youknowone/32/19382_2.png) [@youknowone](https://discuss.python.org/u/youknowone)\
**Post date:** [May 12, 2024, 2:43am UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/26 "2024-05-12T02:43:48Z")

</div>

Thank you for mentioning! I didn’t know about distutils at the moment. I am adding it to deadlibs.

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [May 12, 2024, 3:38am UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/27 "2024-05-12T03:38:11Z")

</div>

> [@gcewing](#):
>
> The trouble is that the new packaging stuff intended to replace it only  
> covers part of its functionality.

Is there a proper overview somewhere of exactly what the full functionality is?

---

<div class="post-metadata">

**Author:** ![oscarbenjamin](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/oscarbenjamin/32/1209_2.png) [@oscarbenjamin](https://discuss.python.org/u/oscarbenjamin)\
**Post date:** [May 12, 2024, 5:15pm UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/28 "2024-05-12T17:15:33Z")

</div>

If you are looking for a Python-based build system for non-Python projects then I can recommend [meson](https://mesonbuild.com/). If you want to build Python packages with meson then you can use [meson-python](https://mesonbuild.com/meson-python/).

Meson can handle different compilers etc for you and is actively maintained. Meson-python is one of many possible candidates that you might choose to use when migrating from Python packaging to distutils via PEP 517 (a build-system independent format for source trees). Both numpy and scipy now use meson and meson-python for development and building. I have personally ported python-flint from distutils/setuptools to meson/meson-python and I am happy with the improvements in compiler detection, reduced build times, editable installs for C code, deterministic rebuilds etc.

As @gcewing says distutils has design problems that are unfixable without a complete rewrite. That is why no one wants to “maintain” it: all existing bugs and limitations are unfixable. The best anyone can offer as maintenance is what is described [here](https://github.com/youknowone/python-deadlib?tab=readme-ov-file#contribution-guideline)

> Please do _NOT_ submit any new features or any compatibility work. This repository is archiving the old standard library installable via pip.

Any other kind of maintenance besides posting an archive for download would entail making changes to distutils and could only lead to any significant improvement by breaking most current usage of distutils.

---

<div class="post-metadata">

**Author:** ![ZeroIntensity](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zerointensity/32/10639_2.png) [@ZeroIntensity](https://discuss.python.org/u/ZeroIntensity)\
**Post date:** [May 12, 2024, 5:28pm UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/29 "2024-05-12T17:28:32Z")

</div>

My proposal was just for general-purpose use, not specific to packaging.

---

<div class="post-metadata">

**Author:** ![oscarbenjamin](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/oscarbenjamin/32/1209_2.png) [@oscarbenjamin](https://discuss.python.org/u/oscarbenjamin)\
**Post date:** [May 12, 2024, 5:44pm UTC](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115/30 "2024-05-12T17:44:08Z")

</div>

Meson is for general purpose project building and is not specific to packaging Python projects.

My answer is not only intended for you though but also people such as @gcewing who wants to make extension modules for the current Python installation: that is something that meson can do with its [Python module](https://mesonbuild.com/Python-module.html). Other people looking to replace distutils are likely looking to build Python packages and meson with meson-python can do that as well.

Basically distutils is unfixable and should be replaced by things that involve complete rewrites of any functionality that it provides. One such candidate for that is meson.

[Previous page](https://discuss.python.org/t/adding-the-old-distutils-ccompiler-to-the-stdlib/53115.md?page=1)
