Movatterモバイル変換


[0]ホーム

URL:


Following system colour schemeSelected dark colour schemeSelected light colour scheme

Python Enhancement Proposals

PEP 775 – Make zlib required to build CPython

Author:
Gregory P. Smith <greg at krypto.org>,Stan Ulbrych <stanulbrych at gmail.com>,Petr Viktorin <encukou at gmail.com>
Discussions-To:
Discourse thread
Status:
Withdrawn
Type:
Standards Track
Created:
24-Feb-2025
Python-Version:
3.14
Post-History:
23-Jan-2023,01-Mar-2025

Table of Contents

Abstract

Building CPython without thezlib compression librarywill no be longer supported, and thezlib module will be required inthe standard library.The only exception isWASI, as zlib is not currentlysupported in CPython on WASI.Building the interpreter without zlib may still be possible,but formally unsupported.

PEP Withdrawal

This PEP was withdrawn by the authors on 2025-05-07. After further reflection,we realized it did not provide sufficient value and was met with significantnegative feedback, particularly regarding the proposed exception for WASI.

Motivation

The zlib library, which powers thezlib Python module,is available on all supported systems except WASI.

Many wheels on PyPI, including thepip 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 timeof writing, at least one CPython test fails without zlib (the “skip”decorator intest_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; weshould just say so.

Rationale

There are possible use cases for zlib-less builds, such as embedding andbootstrapping, as well as unforeseen ones.Therefore, we don’tremove support for zlib-less systems; we mark themunsupported and invite affected users to do their own testing, or to shareuse cases that can make us reconsider this decision.

zlib is not yet used by default on the WASI platform – mostly becauseadding it hasn’t yet been a priority there. (Note thatPyodide, the main“real-world” CPython distribution for WASI, does include zlib.)We take this as an opportunity to continue testing a platform withoutzlib, so that we don’t unintentionally break unsupported builds yet.

Specification

In standard library modules that use zlib for optional functionality,that functionality will raiseImportError when used.Code to generate more “friendly” error messages, or to pre-check whetherzlib is available, will be removed.All functionality unrelated to zlib will still be usable if zlib ismissing.

This affects the following modules, and more that depend on thesetransitively:

shutil.get_archive_formats() will always includezip andgztaras registered formats, even if they are unusable due to missing zlib.

Theconfigure script will issue a warning when zlib is not found onplatforms 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 benefitof WASI, unsupported builds, and any possible reverts.

PEP 11 will be adjusted to mark “Systems without zlib, except WASI” asunsupported.

Backwards Compatibility

In practice, nothing major changes, except in error cases – for example,attempts to use tar compression without zlib available will raiseImportError and notCompressionError.

Security Implications

None known.

How to Teach This

We don’t expect that any instructions will need to change, as zlib isalready available in all relevant contexts.

Reference Implementation

A reference implementation may be found in a pull request to the CPythonrepository,python/cpython#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 theconfigure scriptraise a hard error, and removing@test.support.requires_zlib.

Copyright

This document is placed in the public domain or under theCC0-1.0-Universal license, whichever is more permissive.


Source:https://github.com/python/peps/blob/main/peps/pep-0775.rst

Last modified:2025-05-09 13:52:32 GMT


[8]ページ先頭

©2009-2025 Movatter.jp