Bring back removed features, add deprecations and Release notes

This commit is contained in:
Aleksandr Karpinskii 2024-07-08 20:07:43 +04:00
parent a3468996c0
commit 56ca359c65
5 changed files with 35 additions and 1 deletions

View File

@ -27,6 +27,9 @@ def test_wheel_codecs() -> None:
def test_wheel_features() -> None:
expected_features = {
"webp_anim",
"webp_mux",
"transp_webp",
"raqm",
"fribidi",
"harfbuzz",

View File

@ -46,6 +46,18 @@ def test_version() -> None:
test(feature, features.version_feature)
def test_webp_transparency() -> None:
assert features.check("transp_webp") == features.check_module("webp")
def test_webp_mux() -> None:
assert features.check("webp_mux") == features.check_module("webp")
def test_webp_anim() -> None:
assert features.check("webp_anim") == features.check_module("webp")
@skip_unless_feature("libjpeg_turbo")
def test_libjpeg_turbo_version() -> None:
version = features.version("libjpeg_turbo")

View File

@ -57,6 +57,9 @@ Support for the following features can be checked:
* ``raqm``: Raqm library, required for ``ImageFont.Layout.RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer.
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
* ``xcb``: (compile time) Support for X11 in :py:func:`PIL.ImageGrab.grab` via the XCB library.
* ``transp_webp``: Deprecated. Always ``True`` if WebP module is installed.
* ``webp_mux``: Deprecated. Always ``True`` if WebP module is installed.
* ``webp_anim``: Deprecated. Always ``True`` if WebP module is installed.
.. autofunction:: PIL.features.check_feature
.. autofunction:: PIL.features.version_feature

View File

@ -58,6 +58,14 @@ JpegImageFile.huffman_ac and JpegImageFile.huffman_dc
The ``huffman_ac`` and ``huffman_dc`` dictionaries on JPEG images were unused. They
have been deprecated, and will be removed in Pillow 12 (2025-10-15).
Specific WebP Feature Checks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The following features ``features.check("transp_webp")``,
``features.check("webp_mux")``, and ``features.check("webp_anim")`` are now
always ``True`` if the WebP module is installed and should not be used.
These checks will be removed in Pillow 12.0.0 (2025-10-15).
API Changes
===========

View File

@ -7,6 +7,7 @@ import warnings
from typing import IO
import PIL
from PIL import _deprecate
from . import Image
@ -119,6 +120,9 @@ def get_supported_codecs() -> list[str]:
features = {
"webp_anim": ("PIL._webp", True, None),
"webp_mux": ("PIL._webp", True, None),
"transp_webp": ("PIL._webp", True, None),
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
@ -144,7 +148,11 @@ def check_feature(feature: str) -> bool | None:
try:
imported_module = __import__(module, fromlist=["PIL"])
return getattr(imported_module, flag)
if isinstance(flag, str):
return getattr(imported_module, flag)
else:
_deprecate.deprecate(f'check_feature("{feature}")', 12)
return flag
except ModuleNotFoundError:
return None
except ImportError as ex: