# Lets make \`zlib\` required rather than optional to build CPython

**URL:** <https://discuss.python.org/t/lets-make-zlib-required-rather-than-optional-to-build-cpython/23062>\
**Category:** Core Development\
**Tags:** build\
**Created:** [January 23, 2023, 4:43am UTC](https://discuss.python.org/t/lets-make-zlib-required-rather-than-optional-to-build-cpython/23062 "2023-01-23T04:43:58Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![encukou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/encukou/32/2461_2.png) [@encukou](https://discuss.python.org/u/encukou)\
**Post date:** [October 16, 2024, 9:17am UTC](https://discuss.python.org/t/lets-make-zlib-required-rather-than-optional-to-build-cpython/23062/17 "2024-10-16T09:17:13Z")

</div>

You need zlib to install `pip`, as both the wheel and sdist are compressed. The problem is not 300 extra lines of code. It’s that practically, for most users, CPython without `zlib` is broken.  
But,

- zlib-less builds of CPython _might_ still be useful in some special cases.
- Requiring zlib for WASI is not (and should not be) a priority. I haven’t looked at Android and iOS; this discussion might predate their support.

Let’s make that official. I propose to change our messaging, not (much) code.

Here’s a concrete proposal. Where I say WASI, Android/iOS (or any other platform) can be added if needed.

* * *

The 3.14 What’s New should say:

> `zlib` is now officially required to build CPython.  
> It is still technically possible to build CPython without it for special needs, like bootstrapping. Such builds are not supported, but we can accept pull requests to keep them working.  
> As an exception, `zlib` is not required on WASI.

`Lib/test/test_zlib.py` should add the following comment, and a `zlib`-less build should fail with an error message that points to it. This serves as a deprecation warning. (On WASI the tests should instead continue to be skipped.)

> Building CPython without `zlib` is not supported.  
> Anyone who wants build CPython this way should be prepared to patch it, but the core team may help getting those patches to the `main` branch (as that’s the place where multiple third parties can cooperate).
> 
> For tests to pass without `zlib`, this file needs to be removed.

Existing tests skips (e.g. `@requires_zlib()`) stay in (except in `test_zlib.py` itself, as above).  
`binascii`’s reimplementation of crc32 is removed; corresponding tests are skipped.  
Code that only generates nice error messages in `zlib`-less builds is removed. Corresponding tests are adjusted.

[PEP 11](https://peps.python.org/pep-0011/#no-longer-supported-platforms) gets a new entry:

- Name: Systems without `zlib`, except WASI
- Unsupported in: Python 3.14
- Code removed in: Unknown (see `Lib/test/test_zlib.py` for details)

`configure` is changed to produce a warning on systems without `zlib`, except WASI.

* * *

Note that the WASI exception means that we’ll still test some `zlib`-less build. That’s a good thing.  
Getting zlib there is the opposite of a blocker issue: I’d prefer that to happen well after this change.

---

_[View the full topic](https://discuss.python.org/t/lets-make-zlib-required-rather-than-optional-to-build-cpython/23062)._
