-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 1 commit
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,134 @@ | ||
| PEP: 775 | ||
| Title: Make zlib required to build Python | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| Author: Stan Ulbrych <stanulbrych@gmail.com>, | ||
| Petr Viktorin <encukou@gmail.com> | ||
| Discussions-To: https://discuss.python.org/t/lets-make-zlib-required-rather-than-optional-to-build-cpython/23062 | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| Status: Draft | ||
| Type: Standards Track | ||
|
StanFromIreland marked this conversation as resolved.
|
||
| Created: 20-Feb-2025 | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| Python-Version: 3.14 | ||
| Post-History: `23-Jan-2023 <https://discuss.python.org/t/23062>`__ | ||
|
|
||
|
StanFromIreland marked this conversation as resolved.
|
||
| Abstract | ||
| ======== | ||
|
|
||
| Building CPython on systems without the ``zlib`` compression library, except WASI, | ||
| is no longer supported. | ||
|
|
||
| The ``zlib`` module is made a required part of the standard library, | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| except on WASI. | ||
|
|
||
| Builds without ``zlib`` will still be possible, but formally unsupported. | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| Motivation | ||
| ========== | ||
|
|
||
| The ``zlib`` library, which powers the ``zlib`` Python module, | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| is available on virtually all systems. | ||
|
|
||
| Many wheels on PyPI, including the `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``. | ||
|
|
||
| .. _pip: https://pypi.org/project/pip/ | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
| CPython developers don't really notice either. It turns out that at the time | ||
| of this 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. | ||
|
StanFromIreland marked this conversation as resolved.
|
||
|
|
||
| This PEP treats this as an issue in documentation and messaging. | ||
| In practice, we already don't support building CPython without ``zlib``; we | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| 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. | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
|
StanFromIreland marked this conversation as 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 | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| ``zlib`` is available, will be removed. | ||
| All non-``zlib``-related functionality will still be usable if ``zlib`` is | ||
| missing. | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
| This affects the following modules, and more that depend on these | ||
| transitively: | ||
|
|
||
| * ``shutil`` (``gztar`` and ``zip`` archive formats) | ||
| * ``tarfile``, ``zipfile``, ``zipimport``, ``zipapp`` (archive compression) | ||
| * ``codecs`` (``zlib_codec``) | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
| ``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 | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| unsupported. | ||
|
|
||
|
|
||
| Backwards Compatibility | ||
| ======================= | ||
|
|
||
| In practice, nothing major changes, except in error cases -- for example, | ||
| attempts to use tar compression withoutt ``zlib`` available will raise | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| ``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 | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| already available in all relevant contexts. | ||
|
|
||
|
|
||
| Reference Implementation | ||
| ======================== | ||
|
|
||
| https://github.com/python/cpython/pull/130297 | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| Future work | ||
| =========== | ||
|
|
||
| In the future, if no use cases for ``zlib``-less builds are found, | ||
| ``zlib`` may be made fully required. | ||
|
StanFromIreland marked this conversation as resolved.
Outdated
|
||
| 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.