Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2364fba
Add Android to wheels.yml, wheels-dependencies.sh and pyproject.toml
mhsmith Oct 17, 2026
622b736
Merge branch 'main' into android
radarhere Oct 20, 2026
7c6b487
Merge branch 'main' into android
radarhere Oct 21, 2026
264f972
Merge branch 'main' into android
radarhere Oct 25, 2026
3cafaec
Temporarily disable some workflows
mhsmith Oct 17, 2026
6d720b9
Switch to shared libraries
mhsmith Oct 17, 2026
f77be13
Temporarily remove path and tag filters from wheels.yml
mhsmith Oct 17, 2026
e7619c4
Install pkg-config using pip, and move all pip dependencies to build-…
mhsmith Oct 17, 2026
3cd6402
All dependencies compiling
mhsmith Oct 19, 2026
ae5282c
Wheel build and repair working
mhsmith Oct 20, 2026
efc79f0
Move build tools installation back from build-system.requires to whee…
mhsmith Oct 22, 2026
96ac6cc
Miscellaneous fixes
mhsmith Oct 22, 2026
eb9a43e
Use same AOM / dav1d configuration as iOS
mhsmith Oct 24, 2026
1bbc4d3
Revert Linux to using BUILD_PREFIX=/usr/local
mhsmith Oct 24, 2026
03d6d21
Use the same cross venv workaround on both Android and iOS
mhsmith Oct 24, 2026
6bd96f4
Don't run wheels-dependencies.sh on Windows
mhsmith Oct 24, 2026
374beb5
Add $BUILD_PREFIX/share/pkgconfig to PKG_CONFIG_PATH
mhsmith Oct 24, 2026
e04ee37
Partly unify test scripts
mhsmith Oct 24, 2026
25d534c
More pkg-config fixes
mhsmith Oct 24, 2026
cabe03c
zlib-ng and tiff fixes; all Android tests passing locally
mhsmith Oct 24, 2026
9019fd1
macOS x86_64 debugging
mhsmith Oct 25, 2026
2c11ab8
Revert temporary changes
mhsmith Oct 25, 2026
a696541
Cleanups
mhsmith Oct 25, 2026
22c1120
Don't set PKG_CONFIG_LIBDIR on Linux
mhsmith Oct 25, 2026
21b084a
Merge branch 'main' into android
radarhere Oct 27, 2026
e1aca96
Merge branch 'main' into android
radarhere Oct 31, 2026
b75d596
Merge branch 'main' into android
radarhere Nov 11, 2026
6c4a495
Merge remote-tracking branch 'origin/main' into android-fork
mhsmith Nov 16, 2026
02b59e6
Fix license concatentation
mhsmith Nov 16, 2026
46db25d
Fix wheels-dependencies.sh to work under oss-fuzz
mhsmith Nov 18, 2026
f252f89
Update bzip2 patch to use ?=
mhsmith Nov 18, 2026
8781b7c
Add release note for removal of XCB from iOS wheels
mhsmith Nov 18, 2026
d2aa30c
Add share/pkgconfig to PKG_CONFIG_PATH in setup.py
mhsmith Nov 18, 2026
6a92ebb
Add missing IS_LINUX check to build_zlib_ng
mhsmith Nov 18, 2026
c604345
Use set
radarhere Nov 23, 2026
f2ba2dc
Merge branch 'main' into android
radarhere Nov 24, 2026
322f146
Use set
radarhere Nov 24, 2026
2792e6a
Add IS_IOS
radarhere Nov 24, 2026
63ae95c
Add IS_MOBILE
radarhere Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 179 additions & 101 deletions .github/workflows/wheels-dependencies.sh

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions .github/workflows/wheels-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@ if (Test-Path $venv\Scripts\pypy.exe) {
cd $pillow
& $venv\Scripts\$python -VV
if (!$?) { exit $LASTEXITCODE }
& $venv\Scripts\$python selftest.py
if (!$?) { exit $LASTEXITCODE }
& $venv\Scripts\$python -m pytest -vv -x checks\check_wheel.py
if (!$?) { exit $LASTEXITCODE }
& $venv\Scripts\$python -m pytest -vv -x --numprocesses=logical --dist=worksteal Tests
& $venv\Scripts\$python -m wheels_test
if (!$?) { exit $LASTEXITCODE }
4 changes: 1 addition & 3 deletions .github/workflows/wheels-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@ if [ ! -d "test-images-main" ]; then
fi

# Runs tests
python3 selftest.py
python3 -m pytest -vv -x checks/check_wheel.py
python3 -m pytest -vv -x --numprocesses=logical --dist=worksteal
python3 -m wheels_test
10 changes: 9 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ concurrency:
cancel-in-progress: true

env:
EXPECTED_DISTS: 83
EXPECTED_DISTS: 89
FORCE_COLOR: 1

jobs:
Expand Down Expand Up @@ -120,6 +120,14 @@ jobs:
os: ubuntu-24.04-arm
cibw_arch: aarch64
build: "*musllinux*"
- name: "Android arm64"
platform: android
os: ubuntu-latest
cibw_arch: arm64_v8a
- name: "Android x86_64"
platform: android
os: ubuntu-latest
cibw_arch: x86_64
- name: "iOS arm64 device"
platform: ios
os: macos-latest
Expand Down
5 changes: 4 additions & 1 deletion Tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import pytest


@pytest.mark.skipif(sys.platform == "ios", reason="Processes not supported on iOS")
@pytest.mark.skipif(
sys.platform in {"android", "ios"},
reason="Subprocesses not supported on this platform",
)
@pytest.mark.parametrize(
"args, report",
((["PIL"], False), (["PIL", "--report"], True), (["PIL.report"], True)),
Expand Down
10 changes: 7 additions & 3 deletions checks/check_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def test_wheel_modules() -> None:
if platform.machine() == "ARM64":
expected_modules.remove("avif")

elif sys.platform == "ios":
# tkinter is not available on iOS
elif sys.platform in {"android", "ios"}:
# tkinter is not available on mobile devices
expected_modules.remove("tkinter")

assert set(features.get_supported_modules()) == expected_modules
Expand Down Expand Up @@ -58,7 +58,11 @@ def test_wheel_features() -> None:

if sys.platform == "win32":
expected_features.remove("xcb")
elif sys.platform == "ios":

elif sys.platform in {"android", "ios"}:
# There's no X server on mobile devices.
expected_features.remove("xcb")

# Can't distribute raqm due to licensing, and there's no system version;
# fribidi and harfbuzz won't be available if raqm isn't available.
expected_features -= {"raqm", "fribidi", "harfbuzz"}
Expand Down
10 changes: 10 additions & 0 deletions docs/releasenotes/13.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ Coordinates ending in .5 were rounded to the nearest even integer, so a box of t
size could give an image one pixel larger or smaller depending on where it was. They
are now always rounded up.

Android
^^^^^^^

Android ARM64 and x86_64 wheels are now built for Python 3.13 and later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this mention that it doesn't build threaded versions?


iOS
^^^

iOS wheels no longer include XCB, because there's no X server on iOS devices.

Scaling empty text
^^^^^^^^^^^^^^^^^^

Expand Down
37 changes: 37 additions & 0 deletions patches/bzip2-1.0.8.tar.gz.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--- Makefile 2019-07-13 18:50:05
+++ Makefile 2026-10-19 19:45:39
@@ -15,13 +15,14 @@
SHELL=/bin/sh

# To assist in cross-compiling
-CC=gcc
-AR=ar
-RANLIB=ranlib
-LDFLAGS=
+# Pillow: changed = to ?= or += to allow environment variables to take effect
+CC?=gcc
+AR?=ar
+RANLIB?=ranlib
+LDFLAGS+=

BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS+=-Wall -Winline -O2 -g $(BIGFILES)

# Where you want it installed when you do 'make install'
PREFIX=/usr/local
--- Makefile-libbz2_so 2019-07-13 18:50:05
+++ Makefile-libbz2_so 2026-10-19 19:45:31
@@ -22,9 +22,10 @@


SHELL=/bin/sh
-CC=gcc
+# Pillow: changed = to ?= or += to allow environment variables to take effect
+CC?=gcc
BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS+=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)

OBJS= blocksort.o \
huffman.o \
51 changes: 27 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dynamic.version = { attr = "PIL.__version__" }
[tool.cibuildwheel]
build-verbosity = 1
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
before-all = ".github/workflows/wheels-dependencies.sh"
before-build = ".github/workflows/wheels-dependencies.sh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before-build runs once per build; before-all runs once per job. One of the things that the wheels dependency script does is accumulate licenses in the LICENSES file; so this change results in license text being accumulated multiple times.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree modifying a source-controlled file during the build isn't ideal, but I think fixing that in this PR would touch too many things, because WIndows has its own separate license concatenation script elsewhere in wheels.yml.

Instead, I've added some code to the bottom of wheels-dependencies.sh which detects when the LICENSE file has already been appended, and avoids appending it again. Any other unstaged changes to the file will show an error and stop the build.

test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-requires = [
"numpy",
Expand All @@ -110,36 +110,39 @@ test-extras = "tests"
# Disable platform guessing on macOS to avoid picking up Homebrew etc.
macos.config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable platform-guessing=disable"
# Isolate macOS build environment from Homebrew etc.
macos.environment.PATH = """\
$(pwd)/build/deps/darwin/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin\
"""
# Disable platform guessing on iOS, and disable raqm (since there won't be a
macos.environment.PATH = "$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
# Windows uses build_dep_all.cmd instead of wheels-dependencies.sh.
windows.before-build = ""
# Tell auditwheel where to find dependencies.
android.environment.AUDITWHEEL_LD_LIBRARY_PATH = "$(pwd)/build/deps/current/prefix/lib"

# Settings for mobile platforms
[[tool.cibuildwheel.overrides]]
select = [ "*-android_*", "*-ios_*" ]
# Disable platform guessing, and disable raqm (since there won't be a
# vendor version, and we can't distribute it due to licensing)
ios.config-settings = "raqm=disable imagequant=disable platform-guessing=disable"
# iOS needs to be given a specific pytest invocation and list of test sources.
ios.test-command = [
"python -m selftest",
"python -m pytest -vv -x -W always checks/check_wheel.py Tests",
]
# There's no numpy wheel for iOS (yet...)
ios.test-requires = []
ios.test-sources = [
config-settings = "raqm=disable imagequant=disable platform-guessing=disable"
# Mobile platforms only support Python test-commands, not shell scripts.
test-command = "python -m wheels_test"
test-sources = [
"checks",
"Tests",
"selftest.py",
"wheels_test.py",
]
overrides = [
# iOS environment is isolated by cibuildwheel, but needs the dependencies
{ select = "*_iphoneos", environment.PATH = "$(pwd)/build/deps/iphoneos/bin:$PATH" },
# iOS simulator environment is isolated by cibuildwheel, but needs the dependencies
{ select = "*_iphonesimulator", environment.PATH = "$(pwd)/build/deps/iphonesimulator/bin:$PATH" },
{ select = "*-win32", test-requires = [] },
# NumPy does not yet have PyPy 3.12 wheels
{ select = "pp312*", test-requires = [] },
xbuild-tools = []

[[tool.cibuildwheel.overrides]]
select = [
# NumPy does not have wheels for these platforms or Python versions.
"*-android_*",
"*-ios_*",
"*-win32",
"pp312*",
# NumPy's PyPy 3.11 wheels fail to import on PyPy 3.11 v8.0.0 for Windows
{ select = "pp311-win_amd64", test-requires = [] },
"pp311-win_amd64",
]
xbuild-tools = []
test-requires = []

[tool.black]
exclude = "wheels/multibuild"
Expand Down
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ def _cmd_exists(cmd: str) -> bool:

def _pkg_config(name: str) -> tuple[list[str], list[str]] | None:
command = os.environ.get("PKG_CONFIG", "pkg-config")
env = os.environ.copy()
if sys.platform in {"android", "darwin", "ios"}:
env["PKG_CONFIG_PATH"] = ":".join(
os.path.abspath(f"build/deps/current/prefix/{subdir}/pkgconfig")
for subdir in ["lib", "share"]
)
Comment thread
mhsmith marked this conversation as resolved.
Resolved

for keep_system in (True, False):
try:
command_libs = [command, "--libs-only-L", name]
Expand All @@ -294,13 +301,13 @@ def _pkg_config(name: str) -> tuple[list[str], list[str]] | None:
command_cflags.append("--silence-errors")
libs = re.split(
r"(^|\s+)-L",
subprocess.check_output(command_libs, stderr=stderr)
subprocess.check_output(command_libs, env=env, stderr=stderr)
.decode("utf8")
.strip(),
)[::2][1:]
cflags = re.split(
r"(^|\s+)-I",
subprocess.check_output(command_cflags).decode("utf8").strip(),
subprocess.check_output(command_cflags, env=env).decode("utf8").strip(),
)[::2][1:]
return libs, cflags
except Exception:
Expand Down Expand Up @@ -941,9 +948,6 @@ def build_extensions(self) -> None:
defs.append(("HAVE_LIBIMAGEQUANT", None))
if feature.get("xcb"):
libs.append(feature.get("xcb"))
if sys.platform == "ios":
# Ensure transitive dependencies are linked.
libs.append("Xau")
defs.append(("HAVE_XCB", None))
if sys.platform == "win32":
libs.extend(["kernel32", "user32", "gdi32"])
Expand Down
30 changes: 30 additions & 0 deletions wheels_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

from __future__ import annotations

import runpy
import sys


def run_module(mod_name, *args):
old_args = sys.argv[1:]
sys.argv[1:] = args
try:
runpy.run_module(mod_name, run_name="__main__", alter_sys=True)
except SystemExit as e:
if e.code not in {0, None}:
raise
finally:
sys.argv[1:] = old_args


if __name__ == "__main__":
run_module("selftest")

pytest_args = ["pytest", "-vv", "-x"]
run_module(*pytest_args, "checks/check_wheel.py")

# Mobile platforms don't support multiple processes.
if sys.platform not in ["android", "ios"]:
pytest_args += ["--numprocesses=logical", "--dist=worksteal"]
run_module(*pytest_args, "Tests")
Loading