Merge branch 'main' into context_manager

This commit is contained in:
Andrew Murray 2025-02-18 08:00:08 +11:00 committed by GitHub
commit 01d5b16c51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 702 additions and 538 deletions

View File

@ -2,12 +2,12 @@
aptget_update() aptget_update()
{ {
if [ ! -z $1 ]; then if [ -n "$1" ]; then
echo "" echo ""
echo "Retrying apt-get update..." echo "Retrying apt-get update..."
echo "" echo ""
fi fi
output=`sudo apt-get update 2>&1` output=$(sudo apt-get update 2>&1)
echo "$output" echo "$output"
if [[ $output == *[WE]:\ * ]]; then if [[ $output == *[WE]:\ * ]]; then
return 1 return 1

View File

@ -35,7 +35,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: ["pypy3.10", "3.10", "3.11", "3.12", "3.13", "3.14"] python-version: ["pypy3.11", "pypy3.10", "3.10", "3.11", "3.12", "3.13", "3.14"]
architecture: ["x64"] architecture: ["x64"]
os: ["windows-latest"] os: ["windows-latest"]
include: include:

View File

@ -41,6 +41,7 @@ jobs:
"ubuntu-latest", "ubuntu-latest",
] ]
python-version: [ python-version: [
"pypy3.11",
"pypy3.10", "pypy3.10",
"3.14", "3.14",
"3.13t", "3.13t",

View File

@ -45,7 +45,7 @@ OPENJPEG_VERSION=2.5.3
XZ_VERSION=5.6.4 XZ_VERSION=5.6.4
TIFF_VERSION=4.6.0 TIFF_VERSION=4.6.0
LCMS2_VERSION=2.16 LCMS2_VERSION=2.16
ZLIB_NG_VERSION=2.2.3 ZLIB_NG_VERSION=2.2.4
LIBWEBP_VERSION=1.5.0 LIBWEBP_VERSION=1.5.0
BZIP2_VERSION=1.0.8 BZIP2_VERSION=1.0.8
LIBXCB_VERSION=1.17.0 LIBXCB_VERSION=1.17.0
@ -54,13 +54,10 @@ BROTLI_VERSION=1.1.0
function build_pkg_config { function build_pkg_config {
if [ -e pkg-config-stamp ]; then return; fi if [ -e pkg-config-stamp ]; then return; fi
# This essentially duplicates the Homebrew recipe # This essentially duplicates the Homebrew recipe
ORIGINAL_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -Wno-int-conversion" build_simple pkg-config 0.29.2 https://pkg-config.freedesktop.org/releases tar.gz \
CFLAGS="$CFLAGS -Wno-int-conversion"
build_simple pkg-config 0.29.2 https://pkg-config.freedesktop.org/releases tar.gz \
--disable-debug --disable-host-tool --with-internal-glib \ --disable-debug --disable-host-tool --with-internal-glib \
--with-pc-path=$BUILD_PREFIX/share/pkgconfig:$BUILD_PREFIX/lib/pkgconfig \ --with-pc-path=$BUILD_PREFIX/share/pkgconfig:$BUILD_PREFIX/lib/pkgconfig \
--with-system-include-path=$(xcrun --show-sdk-path --sdk macosx)/usr/include --with-system-include-path=$(xcrun --show-sdk-path --sdk macosx)/usr/include
CFLAGS=$ORIGINAL_CFLAGS
export PKG_CONFIG=$BUILD_PREFIX/bin/pkg-config export PKG_CONFIG=$BUILD_PREFIX/bin/pkg-config
touch pkg-config-stamp touch pkg-config-stamp
} }
@ -72,6 +69,14 @@ function build_zlib_ng {
&& ./configure --prefix=$BUILD_PREFIX --zlib-compat \ && ./configure --prefix=$BUILD_PREFIX --zlib-compat \
&& make -j4 \ && make -j4 \
&& make install) && make install)
if [ -n "$IS_MACOS" ]; then
# Ensure that on macOS, the library name is an absolute path, not an
# @rpath, so that delocate picks up the right library (and doesn't need
# DYLD_LIBRARY_PATH to be set). The default Makefile doesn't have an
# option to control the install_name.
install_name_tool -id $BUILD_PREFIX/lib/libz.1.dylib $BUILD_PREFIX/lib/libz.1.dylib
fi
touch zlib-stamp touch zlib-stamp
} }
@ -130,15 +135,13 @@ function build {
build_lcms2 build_lcms2
build_openjpeg build_openjpeg
ORIGINAL_CFLAGS=$CFLAGS webp_cflags="-O3 -DNDEBUG"
CFLAGS="$CFLAGS -O3 -DNDEBUG"
if [[ -n "$IS_MACOS" ]]; then if [[ -n "$IS_MACOS" ]]; then
CFLAGS="$CFLAGS -Wl,-headerpad_max_install_names" webp_cflags="$webp_cflags -Wl,-headerpad_max_install_names"
fi fi
build_simple libwebp $LIBWEBP_VERSION \ CFLAGS="$CFLAGS $webp_cflags" build_simple libwebp $LIBWEBP_VERSION \
https://storage.googleapis.com/downloads.webmproject.org/releases/webp tar.gz \ https://storage.googleapis.com/downloads.webmproject.org/releases/webp tar.gz \
--enable-libwebpmux --enable-libwebpdemux --enable-libwebpmux --enable-libwebpdemux
CFLAGS=$ORIGINAL_CFLAGS
build_brotli build_brotli

View File

@ -9,7 +9,6 @@ import os
import shutil import shutil
import subprocess import subprocess
import sys import sys
import sysconfig
import tempfile import tempfile
from collections.abc import Sequence from collections.abc import Sequence
from functools import lru_cache from functools import lru_cache
@ -344,10 +343,6 @@ def is_pypy() -> bool:
return hasattr(sys, "pypy_translation_info") return hasattr(sys, "pypy_translation_info")
def is_mingw() -> bool:
return sysconfig.get_platform() == "mingw"
class CachedProperty: class CachedProperty:
def __init__(self, func: Callable[[Any], Any]) -> None: def __init__(self, func: Callable[[Any], Any]) -> None:
self.func = func self.func = func

View File

@ -26,12 +26,12 @@ def test_sanity() -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(TEST_FILE) im = Image.open(TEST_FILE)
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:

View File

@ -59,12 +59,12 @@ def test_prefix_chunk(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(static_test_file) im = Image.open(static_test_file)
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:

View File

@ -22,9 +22,6 @@ from .helper import (
# sample gif stream # sample gif stream
TEST_GIF = "Tests/images/hopper.gif" TEST_GIF = "Tests/images/hopper.gif"
with open(TEST_GIF, "rb") as f:
data = f.read()
def test_sanity() -> None: def test_sanity() -> None:
with Image.open(TEST_GIF) as im: with Image.open(TEST_GIF) as im:
@ -37,12 +34,12 @@ def test_sanity() -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(TEST_GIF) im = Image.open(TEST_GIF)
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:
@ -783,6 +780,21 @@ def test_dispose2_previous_frame(tmp_path: Path) -> None:
assert im.getpixel((0, 0)) == (0, 0, 0, 255) assert im.getpixel((0, 0)) == (0, 0, 0, 255)
def test_dispose2_without_transparency(tmp_path: Path) -> None:
out = str(tmp_path / "temp.gif")
im = Image.new("P", (100, 100))
im2 = Image.new("P", (100, 100), (0, 0, 0))
im2.putpixel((50, 50), (255, 0, 0))
im.save(out, save_all=True, append_images=[im2], disposal=2)
with Image.open(out) as reloaded:
reloaded.seek(1)
assert reloaded.tile[0].extents == (0, 0, 100, 100)
def test_transparency_in_second_frame(tmp_path: Path) -> None: def test_transparency_in_second_frame(tmp_path: Path) -> None:
out = str(tmp_path / "temp.gif") out = str(tmp_path / "temp.gif")
with Image.open("Tests/images/different_transparency.gif") as im: with Image.open("Tests/images/different_transparency.gif") as im:
@ -1379,17 +1391,17 @@ def test_save_I(tmp_path: Path) -> None:
assert_image_equal(reloaded.convert("L"), im.convert("L")) assert_image_equal(reloaded.convert("L"), im.convert("L"))
def test_getdata() -> None: def test_getdata(monkeypatch: pytest.MonkeyPatch) -> None:
# Test getheader/getdata against legacy values. # Test getheader/getdata against legacy values.
# Create a 'P' image with holes in the palette. # Create a 'P' image with holes in the palette.
im = Image._wedge().resize((16, 16), Image.Resampling.NEAREST) im = Image.linear_gradient(mode="L").resize((16, 16), Image.Resampling.NEAREST)
im.putpalette(ImagePalette.ImagePalette("RGB")) im.putpalette(ImagePalette.ImagePalette("RGB"))
im.info = {"background": 0} im.info = {"background": 0}
passed_palette = bytes(255 - i // 3 for i in range(768)) passed_palette = bytes(255 - i // 3 for i in range(768))
GifImagePlugin._FORCE_OPTIMIZE = True monkeypatch.setattr(GifImagePlugin, "_FORCE_OPTIMIZE", True)
try:
h = GifImagePlugin.getheader(im, passed_palette) h = GifImagePlugin.getheader(im, passed_palette)
d = GifImagePlugin.getdata(im) d = GifImagePlugin.getdata(im)
@ -1403,8 +1415,6 @@ def test_getdata() -> None:
assert h == h_target assert h == h_target
assert d == d_target assert d == d_target
finally:
GifImagePlugin._FORCE_OPTIMIZE = False
def test_lzw_bits() -> None: def test_lzw_bits() -> None:

View File

@ -31,12 +31,12 @@ def test_name_limit(tmp_path: Path) -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(TEST_IM) im = Image.open(TEST_IM)
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:

View File

@ -38,12 +38,12 @@ def test_sanity(test_file: str) -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(test_files[0]) im = Image.open(test_files[0])
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:

View File

@ -25,12 +25,12 @@ def test_sanity() -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(test_file) im = Image.open(test_file)
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:

View File

@ -24,12 +24,12 @@ def test_sanity() -> None:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open(TEST_FILE) im = Image.open(TEST_FILE)
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file() -> None: def test_closed_file() -> None:

View File

@ -1,6 +1,7 @@
from __future__ import annotations from __future__ import annotations
import warnings import warnings
from pathlib import Path
import pytest import pytest
@ -29,6 +30,22 @@ def test_sanity(codec: str, test_path: str, format: str) -> None:
assert im.format == format assert im.format == format
def test_unexpected_end(tmp_path: Path) -> None:
tmpfile = str(tmp_path / "temp.tar")
with open(tmpfile, "w"):
pass
with pytest.raises(OSError, match="unexpected end of tar file"):
with TarIO.TarIO(tmpfile, "test"):
pass
def test_cannot_find_subfile() -> None:
with pytest.raises(OSError, match="cannot find subfile"):
with TarIO.TarIO(TEST_TAR_FILE, "test"):
pass
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file() -> None: def test_unclosed_file() -> None:
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):

View File

@ -69,12 +69,12 @@ class TestFileTiff:
@pytest.mark.skipif(is_pypy(), reason="Requires CPython") @pytest.mark.skipif(is_pypy(), reason="Requires CPython")
def test_unclosed_file(self) -> None: def test_unclosed_file(self) -> None:
def open() -> None: def open_test_image() -> None:
im = Image.open("Tests/images/multipage.tiff") im = Image.open("Tests/images/multipage.tiff")
im.load() im.load()
with pytest.warns(ResourceWarning): with pytest.warns(ResourceWarning):
open() open_test_image()
def test_closed_file(self) -> None: def test_closed_file(self) -> None:
with warnings.catch_warnings(): with warnings.catch_warnings():

View File

@ -22,28 +22,26 @@ def test_sanity() -> None:
Image.new("HSV", (100, 100)) Image.new("HSV", (100, 100))
def wedge() -> Image.Image: def linear_gradient() -> Image.Image:
w = Image._wedge() im = Image.linear_gradient(mode="L")
w90 = w.rotate(90) im90 = im.rotate(90)
(px, h) = w.size (px, h) = im.size
r = Image.new("L", (px * 3, h)) r = Image.new("L", (px * 3, h))
g = r.copy() g = r.copy()
b = r.copy() b = r.copy()
r.paste(w, (0, 0)) r.paste(im, (0, 0))
r.paste(w90, (px, 0)) r.paste(im90, (px, 0))
g.paste(w90, (0, 0)) g.paste(im90, (0, 0))
g.paste(w, (2 * px, 0)) g.paste(im, (2 * px, 0))
b.paste(w, (px, 0)) b.paste(im, (px, 0))
b.paste(w90, (2 * px, 0)) b.paste(im90, (2 * px, 0))
img = Image.merge("RGB", (r, g, b)) return Image.merge("RGB", (r, g, b))
return img
def to_xxx_colorsys( def to_xxx_colorsys(
@ -79,8 +77,8 @@ def to_rgb_colorsys(im: Image.Image) -> Image.Image:
return to_xxx_colorsys(im, colorsys.hsv_to_rgb, "RGB") return to_xxx_colorsys(im, colorsys.hsv_to_rgb, "RGB")
def test_wedge() -> None: def test_linear_gradient() -> None:
src = wedge().resize((3 * 32, 32), Image.Resampling.BILINEAR) src = linear_gradient().resize((3 * 32, 32), Image.Resampling.BILINEAR)
im = src.convert("HSV") im = src.convert("HSV")
comparable = to_hsv_colorsys(src) comparable = to_hsv_colorsys(src)

View File

@ -104,7 +104,6 @@ test-extras = "tests"
[tool.cibuildwheel.macos.environment] [tool.cibuildwheel.macos.environment]
PATH = "$(pwd)/build/deps/darwin/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin" PATH = "$(pwd)/build/deps/darwin/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
DYLD_LIBRARY_PATH = "$(pwd)/build/deps/darwin/lib"
[tool.black] [tool.black]
exclude = "wheels/multibuild" exclude = "wheels/multibuild"

View File

@ -26,17 +26,6 @@ from typing import BinaryIO
from . import FontFile, Image from . import FontFile, Image
bdf_slant = {
"R": "Roman",
"I": "Italic",
"O": "Oblique",
"RI": "Reverse Italic",
"RO": "Reverse Oblique",
"OT": "Other",
}
bdf_spacing = {"P": "Proportional", "M": "Monospaced", "C": "Cell"}
def bdf_char( def bdf_char(
f: BinaryIO, f: BinaryIO,

View File

@ -697,16 +697,21 @@ def _write_multiple_frames(
im_frames[-1].encoderinfo["duration"] += encoderinfo["duration"] im_frames[-1].encoderinfo["duration"] += encoderinfo["duration"]
continue continue
if im_frames[-1].encoderinfo.get("disposal") == 2: if im_frames[-1].encoderinfo.get("disposal") == 2:
if background_im is None: # To appear correctly in viewers using a convention,
# only consider transparency, and not background color
color = im.encoderinfo.get( color = im.encoderinfo.get(
"transparency", im.info.get("transparency", (0, 0, 0)) "transparency", im.info.get("transparency")
) )
if color is not None:
if background_im is None:
background = _get_background(im_frame, color) background = _get_background(im_frame, color)
background_im = Image.new("P", im_frame.size, background) background_im = Image.new("P", im_frame.size, background)
first_palette = im_frames[0].im.palette first_palette = im_frames[0].im.palette
assert first_palette is not None assert first_palette is not None
background_im.putpalette(first_palette, first_palette.mode) background_im.putpalette(first_palette, first_palette.mode)
bbox = _getbbox(background_im, im_frame)[1] bbox = _getbbox(background_im, im_frame)[1]
else:
bbox = (0, 0) + im_frame.size
elif encoderinfo.get("optimize") and im_frame.mode != "1": elif encoderinfo.get("optimize") and im_frame.mode != "1":
if "transparency" not in encoderinfo: if "transparency" not in encoderinfo:
assert im_frame.palette is not None assert im_frame.palette is not None
@ -772,6 +777,7 @@ def _write_multiple_frames(
if not palette: if not palette:
frame_data.encoderinfo["include_color_table"] = True frame_data.encoderinfo["include_color_table"] = True
if frame_data.bbox != (0, 0) + im_frame.size:
im_frame = im_frame.crop(frame_data.bbox) im_frame = im_frame.crop(frame_data.bbox)
offset = frame_data.bbox[:2] offset = frame_data.bbox[:2]
_write_frame_data(fp, im_frame, offset, frame_data.encoderinfo) _write_frame_data(fp, im_frame, offset, frame_data.encoderinfo)

View File

@ -2995,15 +2995,6 @@ class ImageTransformHandler:
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Factories # Factories
#
# Debugging
def _wedge() -> Image:
"""Create grayscale wedge (for debugging only)"""
return Image()._new(core.wedge("L"))
def _check_size(size: Any) -> None: def _check_size(size: Any) -> None:
""" """

View File

@ -47,8 +47,7 @@ class WebPImageFile(ImageFile.ImageFile):
self._decoder = _webp.WebPAnimDecoder(self.fp.read()) self._decoder = _webp.WebPAnimDecoder(self.fp.read())
# Get info from decoder # Get info from decoder
width, height, loop_count, bgcolor, frame_count, mode = self._decoder.get_info() self._size, loop_count, bgcolor, frame_count, mode = self._decoder.get_info()
self._size = width, height
self.info["loop"] = loop_count self.info["loop"] = loop_count
bg_a, bg_r, bg_g, bg_b = ( bg_a, bg_r, bg_g, bg_b = (
(bgcolor >> 24) & 0xFF, (bgcolor >> 24) & 0xFF,

View File

@ -3769,102 +3769,26 @@ static PySequenceMethods image_as_sequence = {
/* type description */ /* type description */
static PyTypeObject Imaging_Type = { static PyTypeObject Imaging_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ImagingCore", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingCore",
sizeof(ImagingObject), /*tp_basicsize*/ .tp_basicsize = sizeof(ImagingObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_dealloc,
/* methods */ .tp_as_sequence = &image_as_sequence,
(destructor)_dealloc, /*tp_dealloc*/ .tp_methods = methods,
0, /*tp_vectorcall_offset*/ .tp_getset = getsetters,
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
&image_as_sequence, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
methods, /*tp_methods*/
0, /*tp_members*/
getsetters, /*tp_getset*/
}; };
static PyTypeObject ImagingFont_Type = { static PyTypeObject ImagingFont_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ImagingFont", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingFont",
sizeof(ImagingFontObject), /*tp_basicsize*/ .tp_basicsize = sizeof(ImagingFontObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_font_dealloc,
/* methods */ .tp_methods = _font_methods,
(destructor)_font_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
_font_methods, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
}; };
static PyTypeObject ImagingDraw_Type = { static PyTypeObject ImagingDraw_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "ImagingDraw", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingDraw",
sizeof(ImagingDrawObject), /*tp_basicsize*/ .tp_basicsize = sizeof(ImagingDrawObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_draw_dealloc,
/* methods */ .tp_methods = _draw_methods,
(destructor)_draw_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
_draw_methods, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
}; };
static PyMappingMethods pixel_access_as_mapping = { static PyMappingMethods pixel_access_as_mapping = {
@ -3876,20 +3800,10 @@ static PyMappingMethods pixel_access_as_mapping = {
/* type description */ /* type description */
static PyTypeObject PixelAccess_Type = { static PyTypeObject PixelAccess_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "PixelAccess", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "PixelAccess",
sizeof(PixelAccessObject), /*tp_basicsize*/ .tp_basicsize = sizeof(PixelAccessObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)pixel_access_dealloc,
/* methods */ .tp_as_mapping = &pixel_access_as_mapping,
(destructor)pixel_access_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
&pixel_access_as_mapping, /*tp_as_mapping*/
0 /*tp_hash*/
}; };
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
@ -4256,7 +4170,6 @@ static PyMethodDef functions[] = {
{"effect_noise", (PyCFunction)_effect_noise, METH_VARARGS}, {"effect_noise", (PyCFunction)_effect_noise, METH_VARARGS},
{"linear_gradient", (PyCFunction)_linear_gradient, METH_VARARGS}, {"linear_gradient", (PyCFunction)_linear_gradient, METH_VARARGS},
{"radial_gradient", (PyCFunction)_radial_gradient, METH_VARARGS}, {"radial_gradient", (PyCFunction)_radial_gradient, METH_VARARGS},
{"wedge", (PyCFunction)_linear_gradient, METH_VARARGS}, /* Compatibility */
/* Drawing support stuff */ /* Drawing support stuff */
{"font", (PyCFunction)_font_new, METH_VARARGS}, {"font", (PyCFunction)_font_new, METH_VARARGS},

View File

@ -1410,36 +1410,11 @@ static struct PyGetSetDef cms_profile_getsetters[] = {
}; };
static PyTypeObject CmsProfile_Type = { static PyTypeObject CmsProfile_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "PIL.ImageCms.core.CmsProfile", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "PIL.ImageCms.core.CmsProfile",
sizeof(CmsProfileObject), /*tp_basicsize*/ .tp_basicsize = sizeof(CmsProfileObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)cms_profile_dealloc,
/* methods */ .tp_methods = cms_profile_methods,
(destructor)cms_profile_dealloc, /*tp_dealloc*/ .tp_getset = cms_profile_getsetters,
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
cms_profile_methods, /*tp_methods*/
0, /*tp_members*/
cms_profile_getsetters, /*tp_getset*/
}; };
static struct PyMethodDef cms_transform_methods[] = { static struct PyMethodDef cms_transform_methods[] = {
@ -1447,36 +1422,10 @@ static struct PyMethodDef cms_transform_methods[] = {
}; };
static PyTypeObject CmsTransform_Type = { static PyTypeObject CmsTransform_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "PIL.ImageCms.core.CmsTransform", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "PIL.ImageCms.core.CmsTransform",
sizeof(CmsTransformObject), /*tp_basicsize*/ .tp_basicsize = sizeof(CmsTransformObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)cms_transform_dealloc,
/* methods */ .tp_methods = cms_transform_methods,
(destructor)cms_transform_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
cms_transform_methods, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
}; };
static int static int

View File

@ -1518,36 +1518,11 @@ static struct PyGetSetDef font_getsetters[] = {
}; };
static PyTypeObject Font_Type = { static PyTypeObject Font_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "Font", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "Font",
sizeof(FontObject), /*tp_basicsize*/ .tp_basicsize = sizeof(FontObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)font_dealloc,
/* methods */ .tp_methods = font_methods,
(destructor)font_dealloc, /*tp_dealloc*/ .tp_getset = font_getsetters,
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
font_methods, /*tp_methods*/
0, /*tp_members*/
font_getsetters, /*tp_getset*/
}; };
static PyMethodDef _functions[] = { static PyMethodDef _functions[] = {

View File

@ -449,7 +449,7 @@ _anim_decoder_get_info(PyObject *self) {
WebPAnimInfo *info = &(decp->info); WebPAnimInfo *info = &(decp->info);
return Py_BuildValue( return Py_BuildValue(
"IIIIIs", "(II)IIIs",
info->canvas_width, info->canvas_width,
info->canvas_height, info->canvas_height,
info->loop_count, info->loop_count,
@ -530,36 +530,10 @@ static struct PyMethodDef _anim_encoder_methods[] = {
// WebPAnimEncoder type definition // WebPAnimEncoder type definition
static PyTypeObject WebPAnimEncoder_Type = { static PyTypeObject WebPAnimEncoder_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "WebPAnimEncoder", /*tp_name */ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "WebPAnimEncoder",
sizeof(WebPAnimEncoderObject), /*tp_basicsize */ .tp_basicsize = sizeof(WebPAnimEncoderObject),
0, /*tp_itemsize */ .tp_dealloc = (destructor)_anim_encoder_dealloc,
/* methods */ .tp_methods = _anim_encoder_methods,
(destructor)_anim_encoder_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
_anim_encoder_methods, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
}; };
// WebPAnimDecoder methods // WebPAnimDecoder methods
@ -573,36 +547,10 @@ static struct PyMethodDef _anim_decoder_methods[] = {
// WebPAnimDecoder type definition // WebPAnimDecoder type definition
static PyTypeObject WebPAnimDecoder_Type = { static PyTypeObject WebPAnimDecoder_Type = {
PyVarObject_HEAD_INIT(NULL, 0) "WebPAnimDecoder", /*tp_name */ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "WebPAnimDecoder",
sizeof(WebPAnimDecoderObject), /*tp_basicsize */ .tp_basicsize = sizeof(WebPAnimDecoderObject),
0, /*tp_itemsize */ .tp_dealloc = (destructor)_anim_decoder_dealloc,
/* methods */ .tp_methods = _anim_decoder_methods,
(destructor)_anim_decoder_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
_anim_decoder_methods, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
}; };
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -256,36 +256,11 @@ static struct PyGetSetDef getseters[] = {
}; };
static PyTypeObject ImagingDecoderType = { static PyTypeObject ImagingDecoderType = {
PyVarObject_HEAD_INIT(NULL, 0) "ImagingDecoder", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingDecoder",
sizeof(ImagingDecoderObject), /*tp_basicsize*/ .tp_basicsize = sizeof(ImagingDecoderObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_dealloc,
/* methods */ .tp_methods = methods,
(destructor)_dealloc, /*tp_dealloc*/ .tp_getset = getseters,
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
methods, /*tp_methods*/
0, /*tp_members*/
getseters, /*tp_getset*/
}; };
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -248,36 +248,11 @@ static struct PyGetSetDef getsetters[] = {
}; };
static PyTypeObject ImagingDisplayType = { static PyTypeObject ImagingDisplayType = {
PyVarObject_HEAD_INIT(NULL, 0) "ImagingDisplay", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingDisplay",
sizeof(ImagingDisplayObject), /*tp_basicsize*/ .tp_basicsize = sizeof(ImagingDisplayObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_delete,
/* methods */ .tp_methods = methods,
(destructor)_delete, /*tp_dealloc*/ .tp_getset = getsetters,
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
methods, /*tp_methods*/
0, /*tp_members*/
getsetters, /*tp_getset*/
}; };
PyObject * PyObject *

View File

@ -323,36 +323,11 @@ static struct PyGetSetDef getseters[] = {
}; };
static PyTypeObject ImagingEncoderType = { static PyTypeObject ImagingEncoderType = {
PyVarObject_HEAD_INIT(NULL, 0) "ImagingEncoder", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingEncoder",
sizeof(ImagingEncoderObject), /*tp_basicsize*/ .tp_basicsize = sizeof(ImagingEncoderObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_dealloc,
/* methods */ .tp_methods = methods,
(destructor)_dealloc, /*tp_dealloc*/ .tp_getset = getseters,
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
methods, /*tp_methods*/
0, /*tp_members*/
getseters, /*tp_getset*/
}; };
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
@ -1253,7 +1228,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) {
PyObject *quality_layers = NULL; PyObject *quality_layers = NULL;
Py_ssize_t num_resolutions = 0; Py_ssize_t num_resolutions = 0;
PyObject *cblk_size = NULL, *precinct_size = NULL; PyObject *cblk_size = NULL, *precinct_size = NULL;
PyObject *irreversible = NULL; int irreversible = 0;
char *progression = "LRCP"; char *progression = "LRCP";
OPJ_PROG_ORDER prog_order; OPJ_PROG_ORDER prog_order;
char *cinema_mode = "no"; char *cinema_mode = "no";
@ -1267,7 +1242,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple( if (!PyArg_ParseTuple(
args, args,
"ss|OOOsOnOOOssbbnz#p", "ss|OOOsOnOOpssbbnz#p",
&mode, &mode,
&format, &format,
&offset, &offset,
@ -1402,7 +1377,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) {
precinct_size, &context->precinct_width, &context->precinct_height precinct_size, &context->precinct_width, &context->precinct_height
); );
context->irreversible = PyObject_IsTrue(irreversible); context->irreversible = irreversible;
context->progression = prog_order; context->progression = prog_order;
context->cinema_mode = cine_mode; context->cinema_mode = cine_mode;
context->mct = mct; context->mct = mct;

View File

@ -149,34 +149,8 @@ static struct PyMethodDef _outline_methods[] = {
}; };
static PyTypeObject OutlineType = { static PyTypeObject OutlineType = {
PyVarObject_HEAD_INIT(NULL, 0) "Outline", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "Outline",
sizeof(OutlineObject), /*tp_basicsize*/ .tp_basicsize = sizeof(OutlineObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)_outline_dealloc,
/* methods */ .tp_methods = _outline_methods,
(destructor)_outline_dealloc, /*tp_dealloc*/
0, /*tp_vectorcall_offset*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
_outline_methods, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
}; };

View File

@ -598,34 +598,11 @@ static PyMappingMethods path_as_mapping = {
}; };
static PyTypeObject PyPathType = { static PyTypeObject PyPathType = {
PyVarObject_HEAD_INIT(NULL, 0) "Path", /*tp_name*/ PyVarObject_HEAD_INIT(NULL, 0).tp_name = "Path",
sizeof(PyPathObject), /*tp_basicsize*/ .tp_basicsize = sizeof(PyPathObject),
0, /*tp_itemsize*/ .tp_dealloc = (destructor)path_dealloc,
/* methods */ .tp_as_sequence = &path_as_sequence,
(destructor)path_dealloc, /*tp_dealloc*/ .tp_as_mapping = &path_as_mapping,
0, /*tp_vectorcall_offset*/ .tp_methods = methods,
0, /*tp_getattr*/ .tp_getset = getsetters,
0, /*tp_setattr*/
0, /*tp_as_async*/
0, /*tp_repr*/
0, /*tp_as_number*/
&path_as_sequence, /*tp_as_sequence*/
&path_as_mapping, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
methods, /*tp_methods*/
0, /*tp_members*/
getsetters, /*tp_getset*/
}; };

View File

@ -10,7 +10,7 @@
// https://raw.githubusercontent.com/python/pythoncapi-compat/main/pythoncapi_compat.h // https://raw.githubusercontent.com/python/pythoncapi-compat/main/pythoncapi_compat.h
// //
// This file was vendored from the following commit: // This file was vendored from the following commit:
// https://github.com/python/pythoncapi-compat/commit/0041177c4f348c8952b4c8980b2c90856e61c7c7 // https://github.com/python/pythoncapi-compat/commit/c84545f0e1e21757d4901f75c47333d25a3fcff0
// //
// SPDX-License-Identifier: 0BSD // SPDX-License-Identifier: 0BSD
@ -22,11 +22,15 @@ extern "C" {
#endif #endif
#include <Python.h> #include <Python.h>
#include <stddef.h> // offsetof()
// Python 3.11.0b4 added PyFrame_Back() to Python.h // Python 3.11.0b4 added PyFrame_Back() to Python.h
#if PY_VERSION_HEX < 0x030b00B4 && !defined(PYPY_VERSION) #if PY_VERSION_HEX < 0x030b00B4 && !defined(PYPY_VERSION)
# include "frameobject.h" // PyFrameObject, PyFrame_GetBack() # include "frameobject.h" // PyFrameObject, PyFrame_GetBack()
#endif #endif
#if PY_VERSION_HEX < 0x030C00A3
# include <structmember.h> // T_SHORT, READONLY
#endif
#ifndef _Py_CAST #ifndef _Py_CAST
@ -290,7 +294,7 @@ PyFrame_GetVarString(PyFrameObject *frame, const char *name)
// bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5 // bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
#if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION) #if PY_VERSION_HEX < 0x030900A5 || (defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000)
static inline PyInterpreterState * static inline PyInterpreterState *
PyThreadState_GetInterpreter(PyThreadState *tstate) PyThreadState_GetInterpreter(PyThreadState *tstate)
{ {
@ -583,7 +587,7 @@ static inline int PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
return 0; return 0;
} }
*pobj = Py_NewRef(obj); *pobj = Py_NewRef(obj);
return (*pobj != NULL); return 1;
} }
#endif #endif
@ -921,7 +925,7 @@ static inline int
PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg) PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg)
{ {
PyObject **dict = _PyObject_GetDictPtr(obj); PyObject **dict = _PyObject_GetDictPtr(obj);
if (*dict == NULL) { if (dict == NULL || *dict == NULL) {
return -1; return -1;
} }
Py_VISIT(*dict); Py_VISIT(*dict);
@ -932,7 +936,7 @@ static inline void
PyObject_ClearManagedDict(PyObject *obj) PyObject_ClearManagedDict(PyObject *obj)
{ {
PyObject **dict = _PyObject_GetDictPtr(obj); PyObject **dict = _PyObject_GetDictPtr(obj);
if (*dict == NULL) { if (dict == NULL || *dict == NULL) {
return; return;
} }
Py_CLEAR(*dict); Py_CLEAR(*dict);
@ -1207,11 +1211,11 @@ static inline int PyTime_PerfCounter(PyTime_t *result)
#endif #endif
// gh-111389 added hash constants to Python 3.13.0a5. These constants were // gh-111389 added hash constants to Python 3.13.0a5. These constants were
// added first as private macros to Python 3.4.0b1 and PyPy 7.3.9. // added first as private macros to Python 3.4.0b1 and PyPy 7.3.8.
#if (!defined(PyHASH_BITS) \ #if (!defined(PyHASH_BITS) \
&& ((!defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x030400B1) \ && ((!defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x030400B1) \
|| (defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03070000 \ || (defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03070000 \
&& PYPY_VERSION_NUM >= 0x07090000))) && PYPY_VERSION_NUM >= 0x07030800)))
# define PyHASH_BITS _PyHASH_BITS # define PyHASH_BITS _PyHASH_BITS
# define PyHASH_MODULUS _PyHASH_MODULUS # define PyHASH_MODULUS _PyHASH_MODULUS
# define PyHASH_INF _PyHASH_INF # define PyHASH_INF _PyHASH_INF
@ -1523,6 +1527,36 @@ static inline int PyLong_GetSign(PyObject *obj, int *sign)
} }
#endif #endif
// gh-126061 added PyLong_IsPositive/Negative/Zero() to Python in 3.14.0a2
#if PY_VERSION_HEX < 0x030E00A2
static inline int PyLong_IsPositive(PyObject *obj)
{
if (!PyLong_Check(obj)) {
PyErr_Format(PyExc_TypeError, "expected int, got %s", Py_TYPE(obj)->tp_name);
return -1;
}
return _PyLong_Sign(obj) == 1;
}
static inline int PyLong_IsNegative(PyObject *obj)
{
if (!PyLong_Check(obj)) {
PyErr_Format(PyExc_TypeError, "expected int, got %s", Py_TYPE(obj)->tp_name);
return -1;
}
return _PyLong_Sign(obj) == -1;
}
static inline int PyLong_IsZero(PyObject *obj)
{
if (!PyLong_Check(obj)) {
PyErr_Format(PyExc_TypeError, "expected int, got %s", Py_TYPE(obj)->tp_name);
return -1;
}
return _PyLong_Sign(obj) == 0;
}
#endif
// gh-124502 added PyUnicode_Equal() to Python 3.14.0a0 // gh-124502 added PyUnicode_Equal() to Python 3.14.0a0
#if PY_VERSION_HEX < 0x030E00A0 #if PY_VERSION_HEX < 0x030E00A0
@ -1693,6 +1727,479 @@ static inline int PyLong_AsUInt64(PyObject *obj, uint64_t *pvalue)
#endif #endif
// gh-102471 added import and export API for integers to 3.14.0a2.
#if PY_VERSION_HEX < 0x030E00A2 && PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
// Helpers to access PyLongObject internals.
static inline void
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
{
#if PY_VERSION_HEX >= 0x030C0000
op->long_value.lv_tag = (uintptr_t)(1 - sign) | ((uintptr_t)(size) << 3);
#elif PY_VERSION_HEX >= 0x030900A4
Py_SET_SIZE(op, sign * size);
#else
Py_SIZE(op) = sign * size;
#endif
}
static inline Py_ssize_t
_PyLong_DigitCount(const PyLongObject *op)
{
#if PY_VERSION_HEX >= 0x030C0000
return (Py_ssize_t)(op->long_value.lv_tag >> 3);
#else
return _PyLong_Sign((PyObject*)op) < 0 ? -Py_SIZE(op) : Py_SIZE(op);
#endif
}
static inline digit*
_PyLong_GetDigits(const PyLongObject *op)
{
#if PY_VERSION_HEX >= 0x030C0000
return (digit*)(op->long_value.ob_digit);
#else
return (digit*)(op->ob_digit);
#endif
}
typedef struct PyLongLayout {
uint8_t bits_per_digit;
uint8_t digit_size;
int8_t digits_order;
int8_t digit_endianness;
} PyLongLayout;
typedef struct PyLongExport {
int64_t value;
uint8_t negative;
Py_ssize_t ndigits;
const void *digits;
Py_uintptr_t _reserved;
} PyLongExport;
typedef struct PyLongWriter PyLongWriter;
static inline const PyLongLayout*
PyLong_GetNativeLayout(void)
{
static const PyLongLayout PyLong_LAYOUT = {
PyLong_SHIFT,
sizeof(digit),
-1, // least significant first
PY_LITTLE_ENDIAN ? -1 : 1,
};
return &PyLong_LAYOUT;
}
static inline int
PyLong_Export(PyObject *obj, PyLongExport *export_long)
{
if (!PyLong_Check(obj)) {
memset(export_long, 0, sizeof(*export_long));
PyErr_Format(PyExc_TypeError, "expected int, got %s",
Py_TYPE(obj)->tp_name);
return -1;
}
// Fast-path: try to convert to a int64_t
PyLongObject *self = (PyLongObject*)obj;
int overflow;
#if SIZEOF_LONG == 8
long value = PyLong_AsLongAndOverflow(obj, &overflow);
#else
// Windows has 32-bit long, so use 64-bit long long instead
long long value = PyLong_AsLongLongAndOverflow(obj, &overflow);
#endif
Py_BUILD_ASSERT(sizeof(value) == sizeof(int64_t));
// the function cannot fail since obj is a PyLongObject
assert(!(value == -1 && PyErr_Occurred()));
if (!overflow) {
export_long->value = value;
export_long->negative = 0;
export_long->ndigits = 0;
export_long->digits = 0;
export_long->_reserved = 0;
}
else {
export_long->value = 0;
export_long->negative = _PyLong_Sign(obj) < 0;
export_long->ndigits = _PyLong_DigitCount(self);
if (export_long->ndigits == 0) {
export_long->ndigits = 1;
}
export_long->digits = _PyLong_GetDigits(self);
export_long->_reserved = (Py_uintptr_t)Py_NewRef(obj);
}
return 0;
}
static inline void
PyLong_FreeExport(PyLongExport *export_long)
{
PyObject *obj = (PyObject*)export_long->_reserved;
if (obj) {
export_long->_reserved = 0;
Py_DECREF(obj);
}
}
static inline PyLongWriter*
PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits)
{
if (ndigits <= 0) {
PyErr_SetString(PyExc_ValueError, "ndigits must be positive");
return NULL;
}
assert(digits != NULL);
PyLongObject *obj = _PyLong_New(ndigits);
if (obj == NULL) {
return NULL;
}
_PyLong_SetSignAndDigitCount(obj, negative?-1:1, ndigits);
*digits = _PyLong_GetDigits(obj);
return (PyLongWriter*)obj;
}
static inline void
PyLongWriter_Discard(PyLongWriter *writer)
{
PyLongObject *obj = (PyLongObject *)writer;
assert(Py_REFCNT(obj) == 1);
Py_DECREF(obj);
}
static inline PyObject*
PyLongWriter_Finish(PyLongWriter *writer)
{
PyObject *obj = (PyObject *)writer;
PyLongObject *self = (PyLongObject*)obj;
Py_ssize_t j = _PyLong_DigitCount(self);
Py_ssize_t i = j;
int sign = _PyLong_Sign(obj);
assert(Py_REFCNT(obj) == 1);
// Normalize and get singleton if possible
while (i > 0 && _PyLong_GetDigits(self)[i-1] == 0) {
--i;
}
if (i != j) {
if (i == 0) {
sign = 0;
}
_PyLong_SetSignAndDigitCount(self, sign, i);
}
if (i <= 1) {
long val = sign * (long)(_PyLong_GetDigits(self)[0]);
Py_DECREF(obj);
return PyLong_FromLong(val);
}
return obj;
}
#endif
#if PY_VERSION_HEX < 0x030C00A3
# define Py_T_SHORT T_SHORT
# define Py_T_INT T_INT
# define Py_T_LONG T_LONG
# define Py_T_FLOAT T_FLOAT
# define Py_T_DOUBLE T_DOUBLE
# define Py_T_STRING T_STRING
# define _Py_T_OBJECT T_OBJECT
# define Py_T_CHAR T_CHAR
# define Py_T_BYTE T_BYTE
# define Py_T_UBYTE T_UBYTE
# define Py_T_USHORT T_USHORT
# define Py_T_UINT T_UINT
# define Py_T_ULONG T_ULONG
# define Py_T_STRING_INPLACE T_STRING_INPLACE
# define Py_T_BOOL T_BOOL
# define Py_T_OBJECT_EX T_OBJECT_EX
# define Py_T_LONGLONG T_LONGLONG
# define Py_T_ULONGLONG T_ULONGLONG
# define Py_T_PYSSIZET T_PYSSIZET
# if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
# define _Py_T_NONE T_NONE
# endif
# define Py_READONLY READONLY
# define Py_AUDIT_READ READ_RESTRICTED
# define _Py_WRITE_RESTRICTED PY_WRITE_RESTRICTED
#endif
// gh-127350 added Py_fopen() and Py_fclose() to Python 3.14a4
#if PY_VERSION_HEX < 0x030E00A4
static inline FILE* Py_fopen(PyObject *path, const char *mode)
{
#if 0x030400A2 <= PY_VERSION_HEX && !defined(PYPY_VERSION)
PyAPI_FUNC(FILE*) _Py_fopen_obj(PyObject *path, const char *mode);
return _Py_fopen_obj(path, mode);
#else
FILE *f;
PyObject *bytes;
#if PY_VERSION_HEX >= 0x03000000
if (!PyUnicode_FSConverter(path, &bytes)) {
return NULL;
}
#else
if (!PyString_Check(path)) {
PyErr_SetString(PyExc_TypeError, "except str");
return NULL;
}
bytes = Py_NewRef(path);
#endif
const char *path_bytes = PyBytes_AS_STRING(bytes);
f = fopen(path_bytes, mode);
Py_DECREF(bytes);
if (f == NULL) {
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, path);
return NULL;
}
return f;
#endif
}
static inline int Py_fclose(FILE *file)
{
return fclose(file);
}
#endif
#if 0x03090000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030E0000 && !defined(PYPY_VERSION)
static inline PyObject*
PyConfig_Get(const char *name)
{
typedef enum {
_PyConfig_MEMBER_INT,
_PyConfig_MEMBER_UINT,
_PyConfig_MEMBER_ULONG,
_PyConfig_MEMBER_BOOL,
_PyConfig_MEMBER_WSTR,
_PyConfig_MEMBER_WSTR_OPT,
_PyConfig_MEMBER_WSTR_LIST,
} PyConfigMemberType;
typedef struct {
const char *name;
size_t offset;
PyConfigMemberType type;
const char *sys_attr;
} PyConfigSpec;
#define PYTHONCAPI_COMPAT_SPEC(MEMBER, TYPE, sys_attr) \
{#MEMBER, offsetof(PyConfig, MEMBER), \
_PyConfig_MEMBER_##TYPE, sys_attr}
static const PyConfigSpec config_spec[] = {
PYTHONCAPI_COMPAT_SPEC(argv, WSTR_LIST, "argv"),
PYTHONCAPI_COMPAT_SPEC(base_exec_prefix, WSTR_OPT, "base_exec_prefix"),
PYTHONCAPI_COMPAT_SPEC(base_executable, WSTR_OPT, "_base_executable"),
PYTHONCAPI_COMPAT_SPEC(base_prefix, WSTR_OPT, "base_prefix"),
PYTHONCAPI_COMPAT_SPEC(bytes_warning, UINT, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(exec_prefix, WSTR_OPT, "exec_prefix"),
PYTHONCAPI_COMPAT_SPEC(executable, WSTR_OPT, "executable"),
PYTHONCAPI_COMPAT_SPEC(inspect, BOOL, _Py_NULL),
#if 0x030C0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(int_max_str_digits, UINT, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(interactive, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(module_search_paths, WSTR_LIST, "path"),
PYTHONCAPI_COMPAT_SPEC(optimization_level, UINT, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(parser_debug, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(platlibdir, WSTR, "platlibdir"),
PYTHONCAPI_COMPAT_SPEC(prefix, WSTR_OPT, "prefix"),
PYTHONCAPI_COMPAT_SPEC(pycache_prefix, WSTR_OPT, "pycache_prefix"),
PYTHONCAPI_COMPAT_SPEC(quiet, BOOL, _Py_NULL),
#if 0x030B0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(stdlib_dir, WSTR_OPT, "_stdlib_dir"),
#endif
PYTHONCAPI_COMPAT_SPEC(use_environment, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(verbose, UINT, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(warnoptions, WSTR_LIST, "warnoptions"),
PYTHONCAPI_COMPAT_SPEC(write_bytecode, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(xoptions, WSTR_LIST, "_xoptions"),
PYTHONCAPI_COMPAT_SPEC(buffered_stdio, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(check_hash_pycs_mode, WSTR, _Py_NULL),
#if 0x030B0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(code_debug_ranges, BOOL, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(configure_c_stdio, BOOL, _Py_NULL),
#if 0x030D0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(cpu_count, INT, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(dev_mode, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(dump_refs, BOOL, _Py_NULL),
#if 0x030B0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(dump_refs_file, WSTR_OPT, _Py_NULL),
#endif
#ifdef Py_GIL_DISABLED
PYTHONCAPI_COMPAT_SPEC(enable_gil, INT, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(faulthandler, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(filesystem_encoding, WSTR, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(filesystem_errors, WSTR, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(hash_seed, ULONG, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(home, WSTR_OPT, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(import_time, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(install_signal_handlers, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(isolated, BOOL, _Py_NULL),
#ifdef MS_WINDOWS
PYTHONCAPI_COMPAT_SPEC(legacy_windows_stdio, BOOL, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(malloc_stats, BOOL, _Py_NULL),
#if 0x030A0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(orig_argv, WSTR_LIST, "orig_argv"),
#endif
PYTHONCAPI_COMPAT_SPEC(parse_argv, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(pathconfig_warnings, BOOL, _Py_NULL),
#if 0x030C0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(perf_profiling, UINT, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(program_name, WSTR, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(run_command, WSTR_OPT, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(run_filename, WSTR_OPT, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(run_module, WSTR_OPT, _Py_NULL),
#if 0x030B0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(safe_path, BOOL, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(show_ref_count, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(site_import, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(skip_source_first_line, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(stdio_encoding, WSTR, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(stdio_errors, WSTR, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(tracemalloc, UINT, _Py_NULL),
#if 0x030B0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(use_frozen_modules, BOOL, _Py_NULL),
#endif
PYTHONCAPI_COMPAT_SPEC(use_hash_seed, BOOL, _Py_NULL),
PYTHONCAPI_COMPAT_SPEC(user_site_directory, BOOL, _Py_NULL),
#if 0x030A0000 <= PY_VERSION_HEX
PYTHONCAPI_COMPAT_SPEC(warn_default_encoding, BOOL, _Py_NULL),
#endif
};
#undef PYTHONCAPI_COMPAT_SPEC
const PyConfigSpec *spec;
int found = 0;
for (size_t i=0; i < sizeof(config_spec) / sizeof(config_spec[0]); i++) {
spec = &config_spec[i];
if (strcmp(spec->name, name) == 0) {
found = 1;
break;
}
}
if (found) {
if (spec->sys_attr != NULL) {
PyObject *value = PySys_GetObject(spec->sys_attr);
if (value == NULL) {
PyErr_Format(PyExc_RuntimeError, "lost sys.%s", spec->sys_attr);
return NULL;
}
return Py_NewRef(value);
}
PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
const PyConfig *config = _Py_GetConfig();
void *member = (char *)config + spec->offset;
switch (spec->type) {
case _PyConfig_MEMBER_INT:
case _PyConfig_MEMBER_UINT:
{
int value = *(int *)member;
return PyLong_FromLong(value);
}
case _PyConfig_MEMBER_BOOL:
{
int value = *(int *)member;
return PyBool_FromLong(value != 0);
}
case _PyConfig_MEMBER_ULONG:
{
unsigned long value = *(unsigned long *)member;
return PyLong_FromUnsignedLong(value);
}
case _PyConfig_MEMBER_WSTR:
case _PyConfig_MEMBER_WSTR_OPT:
{
wchar_t *wstr = *(wchar_t **)member;
if (wstr != NULL) {
return PyUnicode_FromWideChar(wstr, -1);
}
else {
return Py_NewRef(Py_None);
}
}
case _PyConfig_MEMBER_WSTR_LIST:
{
const PyWideStringList *list = (const PyWideStringList *)member;
PyObject *tuple = PyTuple_New(list->length);
if (tuple == NULL) {
return NULL;
}
for (Py_ssize_t i = 0; i < list->length; i++) {
PyObject *item = PyUnicode_FromWideChar(list->items[i], -1);
if (item == NULL) {
Py_DECREF(tuple);
return NULL;
}
PyTuple_SET_ITEM(tuple, i, item);
}
return tuple;
}
default:
Py_UNREACHABLE();
}
}
PyErr_Format(PyExc_ValueError, "unknown config option name: %s", name);
return NULL;
}
static inline int
PyConfig_GetInt(const char *name, int *value)
{
PyObject *obj = PyConfig_Get(name);
if (obj == NULL) {
return -1;
}
if (!PyLong_Check(obj)) {
Py_DECREF(obj);
PyErr_Format(PyExc_TypeError, "config option %s is not an int", name);
return -1;
}
int as_int = PyLong_AsInt(obj);
Py_DECREF(obj);
if (as_int == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_OverflowError,
"config option %s value does not fit into a C int", name);
return -1;
}
*value = as_int;
return 0;
}
#endif // PY_VERSION_HEX > 0x03090000 && !defined(PYPY_VERSION)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -11,12 +11,8 @@ deps =
extras = extras =
tests tests
commands = commands =
make clean
{envpython} -m pip install .
{envpython} selftest.py {envpython} selftest.py
{envpython} -m pytest -W always {posargs} {envpython} -m pytest -W always {posargs}
allowlist_externals =
make
[testenv:lint] [testenv:lint]
skip_install = true skip_install = true

View File

@ -116,12 +116,13 @@ V = {
"HARFBUZZ": "10.2.0", "HARFBUZZ": "10.2.0",
"JPEGTURBO": "3.1.0", "JPEGTURBO": "3.1.0",
"LCMS2": "2.16", "LCMS2": "2.16",
"LIBIMAGEQUANT": "4.3.4",
"LIBPNG": "1.6.46", "LIBPNG": "1.6.46",
"LIBWEBP": "1.5.0", "LIBWEBP": "1.5.0",
"OPENJPEG": "2.5.3", "OPENJPEG": "2.5.3",
"TIFF": "4.6.0", "TIFF": "4.6.0",
"XZ": "5.6.4", "XZ": "5.6.4",
"ZLIBNG": "2.2.3", "ZLIBNG": "2.2.4",
} }
V["LIBPNG_XY"] = "".join(V["LIBPNG"].split(".")[:2]) V["LIBPNG_XY"] = "".join(V["LIBPNG"].split(".")[:2])
@ -335,24 +336,15 @@ DEPS: dict[str, dict[str, Any]] = {
"libs": [r"bin\*.lib"], "libs": [r"bin\*.lib"],
}, },
"libimagequant": { "libimagequant": {
# commit: Merge branch 'master' into msvc (matches 2.17.0 tag) "url": "https://github.com/ImageOptim/libimagequant/archive/{V['LIBIMAGEQUANT']}.tar.gz",
"url": "https://github.com/ImageOptim/libimagequant/archive/e4c1334be0eff290af5e2b4155057c2953a313ab.zip", "filename": f"libimagequant-{V['LIBIMAGEQUANT']}.tar.gz",
"filename": "libimagequant-e4c1334be0eff290af5e2b4155057c2953a313ab.zip",
"license": "COPYRIGHT", "license": "COPYRIGHT",
"patch": {
"CMakeLists.txt": {
"if(OPENMP_FOUND)": "if(false)",
"install": "#install",
# libimagequant does not detect MSVC x86_arm64 cross-compiler correctly
"if(${{CMAKE_SYSTEM_PROCESSOR}} STREQUAL ARM64)": "if({architecture} STREQUAL ARM64)", # noqa: E501
}
},
"build": [ "build": [
*cmds_cmake("imagequant_a"), cmd_cd("imagequant-sys"),
cmd_copy("imagequant_a.lib", "imagequant.lib"), "cargo build --release",
], ],
"headers": [r"*.h"], "headers": ["libimagequant.h"],
"libs": [r"imagequant.lib"], "libs": [r"..\target\release\imagequant_sys.lib"],
}, },
"harfbuzz": { "harfbuzz": {
"url": f"https://github.com/harfbuzz/harfbuzz/archive/{V['HARFBUZZ']}.zip", "url": f"https://github.com/harfbuzz/harfbuzz/archive/{V['HARFBUZZ']}.zip",