mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 02:36:17 +03:00
PIL.features: Add a compile-time zlib-ng feature flag and version number
This commit is contained in:
parent
3e0849bfb5
commit
7885066e5f
|
@ -34,10 +34,13 @@ def test_wheel_features() -> None:
|
|||
"fribidi",
|
||||
"harfbuzz",
|
||||
"libjpeg_turbo",
|
||||
"zlib_ng",
|
||||
"xcb",
|
||||
}
|
||||
|
||||
if sys.platform == "win32":
|
||||
expected_features.remove("xcb")
|
||||
else:
|
||||
expected_features.remove("zlib_ng")
|
||||
|
||||
assert set(features.get_supported_features()) == expected_features
|
||||
|
|
|
@ -54,6 +54,7 @@ Feature version numbers are available only where stated.
|
|||
Support for the following features can be checked:
|
||||
|
||||
* ``libjpeg_turbo``: (compile time) Whether Pillow was compiled against the libjpeg-turbo version of libjpeg. Compile-time version number is available.
|
||||
* ``zlib_ng``: (compile time) Whether Pillow was compiled against the zlib-ng version of zlib. Compile-time version number is available.
|
||||
* ``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.
|
||||
|
|
|
@ -127,6 +127,7 @@ features: dict[str, tuple[str, str | bool, str | None]] = {
|
|||
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
|
||||
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
|
||||
"libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO", "libjpeg_turbo_version"),
|
||||
"zlib_ng": ("PIL._imaging", "HAVE_ZLIBNG", "zlib_ng_version"),
|
||||
"libimagequant": ("PIL._imaging", "HAVE_LIBIMAGEQUANT", "imagequant_version"),
|
||||
"xcb": ("PIL._imaging", "HAVE_XCB", None),
|
||||
}
|
||||
|
@ -308,7 +309,11 @@ def pilinfo(out: IO[str] | None = None, supported_formats: bool = True) -> None:
|
|||
# this check is also in src/_imagingcms.c:setup_module()
|
||||
version_static = tuple(int(x) for x in v.split(".")) < (2, 7)
|
||||
t = "compiled for" if version_static else "loaded"
|
||||
if name == "raqm":
|
||||
if name == "zlib":
|
||||
zlib_ng_version = version_feature("zlib_ng")
|
||||
if zlib_ng_version is not None:
|
||||
v += ", compiled for zlib-ng " + zlib_ng_version
|
||||
elif name == "raqm":
|
||||
for f in ("fribidi", "harfbuzz"):
|
||||
v2 = version_feature(f)
|
||||
if v2 is not None:
|
||||
|
|
|
@ -4397,6 +4397,20 @@ setup_module(PyObject *m) {
|
|||
}
|
||||
#endif
|
||||
|
||||
PyObject *have_zlibng;
|
||||
#ifdef ZLIBNG_VERSION
|
||||
have_zlibng = Py_True;
|
||||
{
|
||||
PyObject *v = PyUnicode_FromString(ZLIBNG_VERSION);
|
||||
PyDict_SetItemString(d, "zlib_ng_version", v ? v : Py_None);
|
||||
Py_XDECREF(v);
|
||||
}
|
||||
#else
|
||||
have_zlibng = Py_False;
|
||||
#endif
|
||||
Py_INCREF(have_zlibng);
|
||||
PyModule_AddObject(m, "HAVE_ZLIBNG", have_zlibng);
|
||||
|
||||
#ifdef HAVE_LIBTIFF
|
||||
{
|
||||
extern const char *ImagingTiffVersion(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user