-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PEP 775: Make zlib required to build CPython #4281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2ca626b
Initial addition of pep 775
StanFromIreland ad45795
Apply suggestions from Petr
StanFromIreland a0743a7
Update links
StanFromIreland b954f78
I hate my editor
StanFromIreland ea8eaa3
Apply suggestions from Hugo
StanFromIreland d366919
Merge branch 'main' into pep-775
StanFromIreland 5f24b67
Apply suggestions from Adam
StanFromIreland 273d8bd
Apply Adam’s rewording
StanFromIreland b1ea46e
Remove 'virtually all'
StanFromIreland b231b0e
Add Greg
StanFromIreland 1f36021
Update title
StanFromIreland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| PEP: 775 | ||
| Title: Make zlib required to build CPython | ||
| Author: Gregory P. Smith <greg@krypto.org>, | ||
gpshead marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Stan Ulbrych <stanulbrych@gmail.com>, | ||
| Petr Viktorin <encukou@gmail.com> | ||
| Discussions-To: https://discuss.python.org/t/23062 | ||
| Status: Draft | ||
| Type: Standards Track | ||
StanFromIreland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Created: 24-Feb-2025 | ||
| Python-Version: 3.14 | ||
| Post-History: `23-Jan-2023 <https://discuss.python.org/t/23062>`__ | ||
|
|
||
StanFromIreland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Abstract | ||
| ======== | ||
|
|
||
| Building CPython without the `zlib <https://zlib.net>`_ compression library | ||
| will no be longer supported, and the :mod:`zlib` module will be required in | ||
| the standard library. | ||
| The only exception is `WASI <https://wasi.dev>`_, as zlib is not currently | ||
| supported in CPython on WASI. | ||
| Building the interpreter without zlib may still be possible, | ||
| but formally unsupported. | ||
|
|
||
|
|
||
| Motivation | ||
| ========== | ||
|
|
||
| The zlib library, which powers the :mod:`!zlib` Python module, | ||
| is available on all supported systems except WASI. | ||
|
|
||
| Many wheels on PyPI, including the :pypi:`pip` installer, require zlib. | ||
| Users of pip would consider CPython without zlib to be broken, | ||
| but mostly don't notice because all major builds of CPython include zlib. | ||
|
|
||
| CPython developers don't really notice either. It turns out that at the time | ||
| of writing, at least one CPython test fails without zlib (the "skip" | ||
| decorator in ``test_peg_generator.test_c_parser`` is applied too late), | ||
| but our CI didn't catch this. | ||
|
|
||
| This PEP treats this as an issue in documentation and messaging. | ||
| In practice, we already don't support building CPython without zlib; we | ||
| should just say so. | ||
|
|
||
|
|
||
| Rationale | ||
| ========= | ||
|
|
||
| There are possible use cases for zlib-less builds, such as embedding and | ||
| bootstrapping, as well as unforeseen ones. | ||
| Therefore, we don't *remove* support for zlib-less systems; we mark them | ||
| unsupported and invite affected users to do their own testing, or to share | ||
| use cases that can make us reconsider this decision. | ||
|
|
||
| zlib is not yet used by default on the WASI platform -- mostly because | ||
| adding it hasn't yet been a priority there. (Note that `Pyodide`_, the main | ||
| "real-world" CPython distribution for WASI, does include zlib.) | ||
| We take this as an opportunity to continue testing a platform without | ||
| zlib, so that we don't unintentionally break unsupported builds yet. | ||
|
|
||
| .. _Pyodide: https://pyodide.org | ||
|
|
||
StanFromIreland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Specification | ||
| ============= | ||
|
|
||
| In standard library modules that use zlib for optional functionality, | ||
| that functionality will raise ``ImportError`` when used. | ||
| Code to generate more "friendly" error messages, or to pre-check whether | ||
| zlib is available, will be removed. | ||
| All functionality unrelated to zlib will still be usable if zlib is | ||
| missing. | ||
|
|
||
| This affects the following modules, and more that depend on these | ||
| transitively: | ||
|
|
||
| * :mod:`shutil` (``gztar`` and ``zip`` archive formats) | ||
| * :mod:`tarfile`, :mod:`zipfile`, :mod:`zipimport`, | ||
| :mod:`zipapp` (archive compression) | ||
| * :mod:`codecs` (``zlib_codec``) | ||
|
|
||
| ``shutil.get_archive_formats()`` will always include ``zip`` and ``gztar`` | ||
| as registered formats, even if they are unusable due to missing zlib. | ||
|
|
||
| The ``configure`` script will issue a warning when zlib is not found on | ||
| platforms other than WASI. | ||
|
|
||
| ``test_zlib`` will fail on platforms other than WASI. | ||
| All other tests will continue to be skipped -- that is, uses of | ||
| ``@test.support.requires_zlib`` will be kept in place -- for the benefit | ||
| of WASI, unsupported builds, and any possible reverts. | ||
|
|
||
| :pep:`11` will be adjusted to mark "Systems without zlib, except WASI" as | ||
| unsupported. | ||
|
|
||
|
|
||
| Backwards Compatibility | ||
| ======================= | ||
|
|
||
| In practice, nothing major changes, except in error cases -- for example, | ||
| attempts to use tar compression without zlib available will raise | ||
| ``ImportError`` and not ``CompressionError``. | ||
|
|
||
|
|
||
| Security Implications | ||
| ===================== | ||
|
|
||
| None known. | ||
|
|
||
|
|
||
| How to Teach This | ||
| ================= | ||
|
|
||
| We don't expect that any instructions will need to change, as zlib is | ||
| already available in all relevant contexts. | ||
|
|
||
|
|
||
| Reference Implementation | ||
| ======================== | ||
|
|
||
| A reference implementation may be found in a pull request to the CPython | ||
| repository, `python/cpython#130297 | ||
| <https://github.com/python/cpython/pull/130297>`_ | ||
|
|
||
|
|
||
| Future work | ||
| =========== | ||
|
|
||
| In the future, if no use cases for zlib-less builds are found, | ||
| zlib may be made fully required. | ||
| The main changes needed for that would be making the ``configure`` script | ||
| raise a hard error, and removing ``@test.support.requires_zlib``. | ||
|
|
||
|
|
||
| Copyright | ||
| ========= | ||
|
|
||
| This document is placed in the public domain or under the | ||
| CC0-1.0-Universal license, whichever is more permissive. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.