You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make zlib required on all platforms (simplifies code) #91246
We have a pile of conditionals and extra code in CPython to deal with building on systems that do not have zlib. The zlib C library has been around forever at this point and should be present on every system in the world.
zlib is already required on Windows to build CPython.
Proposal: simplify our code by removing the conditionals around zlib being optional. I'm attaching a draft PR to show what this would look like.
Bringing this up on discord, others point out that the windows build requires zlib for convenience when we transitioned from having a vendored copy in our repo and that smaller "embedded" use cases may not like this if they don't already need the dep. But there have been no complaints about it on the Windows side.
binascii.crc32 was one thing that motivated me to look into "just require zlib" to get out of carrying our own suboptimal crc32 code.
looking over my PR, it can make for some awkward code with zlib right next to others that we treat as optionals. good bad or indifferent? i'm leaning towards indifferent and still enjoying fewer lines of code.
I've been experimenting with zlib and WASI cpython - if the zlib source is available, then it successfully builds with the WASI SDK and it pretty much just works - the cpython configure & build process detects it, it builds successfully and the zlib module seems to work fine when imported (also passes test_zlib). No code changes needed to either zlib or cpython.
I built zlib with the WASI SDK and these environment variables for configure:
Activity
gpshead commentedon Mar 22, 2022
We have a pile of conditionals and extra code in CPython to deal with building on systems that do not have zlib. The zlib C library has been around forever at this point and should be present on every system in the world.
zlib is already required on Windows to build CPython.
Proposal: simplify our code by removing the conditionals around zlib being optional. I'm attaching a draft PR to show what this would look like.
gpshead commentedon Mar 22, 2022
Bringing this up on discord, others point out that the windows build requires zlib for convenience when we transitioned from having a vendored copy in our repo and that smaller "embedded" use cases may not like this if they don't already need the dep. But there have been no complaints about it on the Windows side.
binascii.crc32was one thing that motivated me to look into "just require zlib" to get out of carrying our own suboptimal crc32 code.looking over my PR, it can make for some awkward code with zlib right next to others that we treat as optionals. good bad or indifferent? i'm leaning towards indifferent and still enjoying fewer lines of code.
gpshead commentedon Jan 23, 2023
discussion started in https://discuss.python.org/t/lets-make-zlib-required-rather-than-optional-to-build-cpython/23062
katharosada commentedon Jun 23, 2023
@brettcannon asked me to update here.
I've been experimenting with zlib and WASI cpython - if the zlib source is available, then it successfully builds with the WASI SDK and it pretty much just works - the cpython configure & build process detects it, it builds successfully and the zlib module seems to work fine when imported (also passes
test_zlib). No code changes needed to either zlib or cpython.I built zlib with the WASI SDK and these environment variables for
configure:Then normal
makeandmake install. I presume it could be installed to a different place if necessary and included but I haven't tried that.Let me know if there's anything you'd like me to change/test, happy to write up PRs etc.
Full Dockerfile for context:
GH-105808: Fix a regression introduced in GH-101251 (#105910)
StanFromIreland commentedon May 9, 2025
PEP 775 – Make zlib required to build CPython was withdrawn.
(This can be closed)