Skip to content

Commit 6938379

Browse files
authored
Merge branch 'main' into fix-qtables-and-quality-scaling
2 parents df7b941 + a370209 commit 6938379

84 files changed

Lines changed: 12832 additions & 416 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ci/requirements-mypy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mypy==1.16.0
1+
mypy==1.16.1
22
IceSpringPySideStubs-PyQt6
33
IceSpringPySideStubs-PySide6
44
ipython

.ci/test.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
python.exe -c "from PIL import Image"
22
IF ERRORLEVEL 1 EXIT /B
3-
python.exe -bb -m pytest -v -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests
3+
python.exe -bb -m pytest -vv -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests

.ci/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -e
44

55
python3 -c "from PIL import Image"
66

7-
python3 -bb -m pytest -v -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests $REVERSE
7+
python3 -bb -m pytest -vv -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests $REVERSE

.github/workflows/wheels-dependencies.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ LIBWEBP_VERSION=1.5.0
5151
BZIP2_VERSION=1.0.8
5252
LIBXCB_VERSION=1.17.0
5353
BROTLI_VERSION=1.1.0
54+
LIBAVIF_VERSION=1.3.0
5455

5556
function build_pkg_config {
5657
if [ -e pkg-config-stamp ]; then return; fi
@@ -98,6 +99,59 @@ function build_harfbuzz {
9899
touch harfbuzz-stamp
99100
}
100101

102+
function build_libavif {
103+
if [ -e libavif-stamp ]; then return; fi
104+
105+
python3 -m pip install meson ninja
106+
107+
if [[ "$PLAT" == "x86_64" ]] || [ -n "$SANITIZER" ]; then
108+
build_simple nasm 2.16.03 https://www.nasm.us/pub/nasm/releasebuilds/2.16.03
109+
fi
110+
111+
local build_type=MinSizeRel
112+
local lto=ON
113+
114+
local libavif_cmake_flags
115+
116+
if [ -n "$IS_MACOS" ]; then
117+
lto=OFF
118+
libavif_cmake_flags=(
119+
-DCMAKE_C_FLAGS_MINSIZEREL="-Oz -DNDEBUG -flto" \
120+
-DCMAKE_CXX_FLAGS_MINSIZEREL="-Oz -DNDEBUG -flto" \
121+
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,-S,-x,-dead_strip_dylibs" \
122+
)
123+
else
124+
if [[ "$MB_ML_VER" == 2014 ]] && [[ "$PLAT" == "x86_64" ]]; then
125+
build_type=Release
126+
fi
127+
libavif_cmake_flags=(-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--strip-all,-z,relro,-z,now")
128+
fi
129+
130+
local out_dir=$(fetch_unpack https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$LIBAVIF_VERSION.tar.gz libavif-$LIBAVIF_VERSION.tar.gz)
131+
# CONFIG_AV1_HIGHBITDEPTH=0 is a flag for libaom (included as a subproject
132+
# of libavif) that disables support for encoding high bit depth images.
133+
(cd $out_dir \
134+
&& cmake \
135+
-DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
136+
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib \
137+
-DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
138+
-DBUILD_SHARED_LIBS=ON \
139+
-DAVIF_LIBSHARPYUV=LOCAL \
140+
-DAVIF_LIBYUV=LOCAL \
141+
-DAVIF_CODEC_AOM=LOCAL \
142+
-DCONFIG_AV1_HIGHBITDEPTH=0 \
143+
-DAVIF_CODEC_AOM_DECODE=OFF \
144+
-DAVIF_CODEC_DAV1D=LOCAL \
145+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=$lto \
146+
-DCMAKE_C_VISIBILITY_PRESET=hidden \
147+
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
148+
-DCMAKE_BUILD_TYPE=$build_type \
149+
"${libavif_cmake_flags[@]}" \
150+
. \
151+
&& make install)
152+
touch libavif-stamp
153+
}
154+
101155
function build {
102156
build_xz
103157
if [ -z "$IS_ALPINE" ] && [ -z "$SANITIZER" ] && [ -z "$IS_MACOS" ]; then
@@ -132,6 +186,7 @@ function build {
132186
build_tiff
133187
fi
134188

189+
build_libavif
135190
build_libpng
136191
build_lcms2
137192
build_openjpeg

.github/workflows/wheels-test.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cd $pillow
2323
if (!$?) { exit $LASTEXITCODE }
2424
& $venv\Scripts\$python selftest.py
2525
if (!$?) { exit $LASTEXITCODE }
26-
& $venv\Scripts\$python -m pytest -vx Tests\check_wheel.py
26+
& $venv\Scripts\$python -m pytest -vv -x Tests\check_wheel.py
2727
if (!$?) { exit $LASTEXITCODE }
28-
& $venv\Scripts\$python -m pytest -vx Tests
28+
& $venv\Scripts\$python -m pytest -vv -x Tests
2929
if (!$?) { exit $LASTEXITCODE }

.github/workflows/wheels-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ fi
3535

3636
# Runs tests
3737
python3 selftest.py
38-
python3 -m pytest Tests/check_wheel.py
39-
python3 -m pytest
38+
python3 -m pytest -vv -x Tests/check_wheel.py
39+
python3 -m pytest -vv -x

.github/workflows/wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: "macOS 10.13 x86_64"
5959
os: macos-13
6060
cibw_arch: x86_64
61-
build: "cp3{12,13}*"
61+
build: "cp3{12,13,14}*"
6262
macosx_deployment_target: "10.13"
6363
- name: "macOS 10.15 x86_64"
6464
os: macos-13
@@ -159,7 +159,7 @@ jobs:
159159
# Install extra test images
160160
xcopy /S /Y Tests\test-images\* Tests\images
161161
162-
& python.exe winbuild\build_prepare.py -v --no-imagequant --no-avif --architecture=${{ matrix.cibw_arch }}
162+
& python.exe winbuild\build_prepare.py -v --no-imagequant --architecture=${{ matrix.cibw_arch }}
163163
shell: pwsh
164164

165165
- name: Build wheels

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.12
3+
rev: v0.12.0
44
hooks:
5-
- id: ruff
5+
- id: ruff-check
66
args: [--exit-non-zero-on-fix]
77

88
- repo: https://github.com/psf/black-pre-commit-mirror
@@ -11,7 +11,7 @@ repos:
1111
- id: black
1212

1313
- repo: https://github.com/PyCQA/bandit
14-
rev: 1.8.3
14+
rev: 1.8.5
1515
hooks:
1616
- id: bandit
1717
args: [--severity-level=high]
@@ -24,7 +24,7 @@ repos:
2424
exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.gd$|\.opt$)
2525

2626
- repo: https://github.com/pre-commit/mirrors-clang-format
27-
rev: v20.1.5
27+
rev: v20.1.6
2828
hooks:
2929
- id: clang-format
3030
types: [c]
@@ -51,7 +51,7 @@ repos:
5151
exclude: ^.github/.*TEMPLATE|^Tests/(fonts|images)/
5252

5353
- repo: https://github.com/python-jsonschema/check-jsonschema
54-
rev: 0.33.0
54+
rev: 0.33.1
5555
hooks:
5656
- id: check-github-workflows
5757
- id: check-readthedocs

Tests/check_wheel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
def test_wheel_modules() -> None:
12-
expected_modules = {"pil", "tkinter", "freetype2", "littlecms2", "webp"}
12+
expected_modules = {"pil", "tkinter", "freetype2", "littlecms2", "webp", "avif"}
1313

1414
if sys.platform == "win32":
1515
# tkinter is not available in cibuildwheel installed CPython on Windows
@@ -20,6 +20,10 @@ def test_wheel_modules() -> None:
2020
except ImportError:
2121
expected_modules.remove("tkinter")
2222

23+
# libavif is not available on Windows for ARM64 architectures
24+
if platform.machine() == "ARM64":
25+
expected_modules.remove("avif")
26+
2327
assert set(features.get_supported_modules()) == expected_modules
2428

2529

Tests/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def _cached_hopper(mode: str) -> Image.Image:
272272
else:
273273
im = hopper()
274274
if mode.startswith("BGR;"):
275-
with pytest.warns(DeprecationWarning):
275+
with pytest.warns(DeprecationWarning, match="BGR;"):
276276
im = im.convert(mode)
277277
else:
278278
try:

0 commit comments

Comments
 (0)