Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere authored Jan 31, 2024
2 parents 9392f24 + db43738 commit e7470ed
Show file tree
Hide file tree
Showing 68 changed files with 349 additions and 237 deletions.
2 changes: 1 addition & 1 deletion .ci/requirements-cibw.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cibuildwheel==2.16.2
cibuildwheel==2.16.5
12 changes: 11 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,26 @@ jobs:
with:
python-version: "3.x"
cache: pip
cache-dependency-path: ".ci/*.sh"
cache-dependency-path: |
".ci/*.sh"
"pyproject.toml"
- name: Build system information
run: python3 .github/workflows/system-info.py

- name: Cache libimagequant
uses: actions/cache@v4
id: cache-libimagequant
with:
path: ~/cache-libimagequant
key: ${{ runner.os }}-libimagequant-${{ hashFiles('depends/install_imagequant.sh') }}

- name: Install Linux dependencies
run: |
.ci/install.sh
env:
GHA_PYTHON_VERSION: "3.x"
GHA_LIBIMAGEQUANT_CACHE_HIT: ${{ steps.cache-libimagequant.outputs.cache-hit }}

- name: Build
run: |
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/macos-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

set -e

brew install libtiff libjpeg openjpeg libimagequant webp little-cms2 freetype libraqm
brew install \
freetype \
ghostscript \
libimagequant \
libjpeg \
libraqm \
libtiff \
little-cms2 \
openjpeg \
webp
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"

# TODO Update condition when cffi supports 3.13
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@v4

- name: Install Cygwin
uses: cygwin/cygwin-install-action@v4
uses: egor-tensin/setup-cygwin@v4
with:
platform: x86_64
packages: >
Expand All @@ -69,6 +69,7 @@ jobs:
make
netpbm
perl
python39=3.9.16-1
python3${{ matrix.python-minor-version }}-cffi
python3${{ matrix.python-minor-version }}-cython
python3${{ matrix.python-minor-version }}-devel
Expand All @@ -86,7 +87,7 @@ jobs:

- name: Select Python version
run: |
ln -sf c:/cygwin/bin/python3.${{ matrix.python-minor-version }} c:/cygwin/bin/python3
ln -sf c:/tools/cygwin/bin/python3.${{ matrix.python-minor-version }} c:/tools/cygwin/bin/python3
- name: Get latest NumPy version
id: latest-numpy
Expand Down
34 changes: 29 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 1

jobs:
build:

strategy:
fail-fast: false
matrix:
os: [
"macos-latest",
"macos-14",
"ubuntu-latest",
]
python-version: [
Expand All @@ -47,11 +50,21 @@ jobs:
"3.8",
]
include:
- python-version: "3.9"
- python-version: "3.11"
PYTHONOPTIMIZE: 1
REVERSE: "--reverse"
- python-version: "3.8"
- python-version: "3.10"
PYTHONOPTIMIZE: 2
# M1 only available for 3.10+
- os: "macos-latest"
python-version: "3.9"
- os: "macos-latest"
python-version: "3.8"
exclude:
- os: "macos-14"
python-version: "3.9"
- os: "macos-14"
python-version: "3.8"

runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
Expand All @@ -65,17 +78,28 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: ".ci/*.sh"
cache-dependency-path: |
".ci/*.sh"
"pyproject.toml"
- name: Build system information
run: python3 .github/workflows/system-info.py

- name: Cache libimagequant
if: startsWith(matrix.os, 'ubuntu')
uses: actions/cache@v4
id: cache-libimagequant
with:
path: ~/cache-libimagequant
key: ${{ runner.os }}-libimagequant-${{ hashFiles('depends/install_imagequant.sh') }}

- name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
.ci/install.sh
env:
GHA_PYTHON_VERSION: ${{ matrix.python-version }}
GHA_LIBIMAGEQUANT_CACHE_HIT: ${{ steps.cache-libimagequant.outputs.cache-hit }}

- name: Install macOS dependencies
if: startsWith(matrix.os, 'macOS')
Expand Down Expand Up @@ -127,7 +151,7 @@ jobs:
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.os == 'macos-latest' && 'GHA_macOS' || 'GHA_Ubuntu' }}
flags: ${{ matrix.os == 'ubuntu-latest' && 'GHA_Ubuntu' || 'GHA_macOS' }}
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
gcov: true

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repos:
rev: v4.5.0
hooks:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-json
- id: check-toml
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Changelog (Pillow)
10.3.0 (unreleased)
-------------------

- Do not support using test-image-results to upload images after test failures #7739
[radarhere]

- Changed ImageMath.ops to be static #7721
[radarhere]

- Fix APNG info after seeking backwards more than twice #7701
[esoma, radarhere]

Expand Down
1 change: 0 additions & 1 deletion Tests/check_fli_oob.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
from __future__ import annotations

from PIL import Image
Expand Down
4 changes: 2 additions & 2 deletions Tests/check_j2k_overflow.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

from pathlib import PosixPath
from pathlib import Path

import pytest

from PIL import Image


def test_j2k_overflow(tmp_path: PosixPath) -> None:
def test_j2k_overflow(tmp_path: Path) -> None:
im = Image.new("RGBA", (1024, 131584))
target = str(tmp_path / "temp.jpc")
with pytest.raises(OSError):
Expand Down
2 changes: 0 additions & 2 deletions Tests/check_jp2_overflow.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

# Reproductions/tests for OOB read errors in FliDecode.c

# When run in python, all of these images should fail for
Expand Down
8 changes: 4 additions & 4 deletions Tests/check_large_memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import sys
from pathlib import PosixPath
from pathlib import Path
from types import ModuleType

import pytest
Expand Down Expand Up @@ -31,18 +31,18 @@
pytestmark = pytest.mark.skipif(sys.maxsize <= 2**32, reason="requires 64-bit system")


def _write_png(tmp_path: PosixPath, xdim: int, ydim: int) -> None:
def _write_png(tmp_path: Path, xdim: int, ydim: int) -> None:
f = str(tmp_path / "temp.png")
im = Image.new("L", (xdim, ydim), 0)
im.save(f)


def test_large(tmp_path: PosixPath) -> None:
def test_large(tmp_path: Path) -> None:
"""succeeded prepatch"""
_write_png(tmp_path, XDIM, YDIM)


def test_2gpx(tmp_path: PosixPath) -> None:
def test_2gpx(tmp_path: Path) -> None:
"""failed prepatch"""
_write_png(tmp_path, XDIM, XDIM)

Expand Down
8 changes: 4 additions & 4 deletions Tests/check_large_memory_numpy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import sys
from pathlib import PosixPath
from pathlib import Path

import pytest

Expand All @@ -25,19 +25,19 @@
pytestmark = pytest.mark.skipif(sys.maxsize <= 2**32, reason="requires 64-bit system")


def _write_png(tmp_path: PosixPath, xdim: int, ydim: int) -> None:
def _write_png(tmp_path: Path, xdim: int, ydim: int) -> None:
dtype = np.uint8
a = np.zeros((xdim, ydim), dtype=dtype)
f = str(tmp_path / "temp.png")
im = Image.fromarray(a, "L")
im.save(f)


def test_large(tmp_path: PosixPath) -> None:
def test_large(tmp_path: Path) -> None:
"""succeeded prepatch"""
_write_png(tmp_path, XDIM, YDIM)


def test_2gpx(tmp_path: PosixPath) -> None:
def test_2gpx(tmp_path: Path) -> None:
"""failed prepatch"""
_write_png(tmp_path, XDIM, XDIM)
9 changes: 0 additions & 9 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
uploader = "show"
elif "GITHUB_ACTIONS" in os.environ:
uploader = "github_actions"
else:
try:
import test_image_results

uploader = "aws"
except ImportError:
pass


def upload(a: Image.Image, b: Image.Image) -> str | None:
Expand All @@ -46,8 +39,6 @@ def upload(a: Image.Image, b: Image.Image) -> str | None:
a.save(os.path.join(tmpdir, "a.png"))
b.save(os.path.join(tmpdir, "b.png"))
return tmpdir
elif uploader == "aws":
return test_image_results.upload(a, b)
return None


Expand Down
2 changes: 0 additions & 2 deletions Tests/images/create_eps.gnuplot
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/gnuplot

#This is the script that was used to create our sample EPS files
#We used the following version of the gnuplot program
#G N U P L O T
Expand Down
2 changes: 0 additions & 2 deletions Tests/oss-fuzz/fuzz_pillow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/python3

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_000_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PIL import Image


def test_sanity():
def test_sanity() -> None:
# Make sure we have the binary extension
Image.core.new("L", (100, 100))

Expand Down
6 changes: 3 additions & 3 deletions Tests/test_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from PIL import _binary


def test_standard():
def test_standard() -> None:
assert _binary.i8(b"*") == 42
assert _binary.o8(42) == b"*"


def test_little_endian():
def test_little_endian() -> None:
assert _binary.i16le(b"\xff\xff\x00\x00") == 65535
assert _binary.i32le(b"\xff\xff\x00\x00") == 65535

assert _binary.o16le(65535) == b"\xff\xff"
assert _binary.o32le(65535) == b"\xff\xff\x00\x00"


def test_big_endian():
def test_big_endian() -> None:
assert _binary.i16be(b"\x00\x00\xff\xff") == 0
assert _binary.i32be(b"\x00\x00\xff\xff") == 65535

Expand Down
4 changes: 2 additions & 2 deletions Tests/test_file_cur.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
TEST_FILE = "Tests/images/deerstalker.cur"


def test_sanity():
def test_sanity() -> None:
with Image.open(TEST_FILE) as im:
assert im.size == (32, 32)
assert isinstance(im, CurImagePlugin.CurImageFile)
Expand All @@ -17,7 +17,7 @@ def test_sanity():
assert im.getpixel((16, 16)) == (84, 87, 86, 255)


def test_invalid_file():
def test_invalid_file() -> None:
invalid_file = "Tests/images/flower.jpg"

with pytest.raises(SyntaxError):
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_file_ftex.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
from .helper import assert_image_equal_tofile, assert_image_similar


def test_load_raw():
def test_load_raw() -> None:
with Image.open("Tests/images/ftex_uncompressed.ftu") as im:
assert_image_equal_tofile(im, "Tests/images/ftex_uncompressed.png")


def test_load_dxt1():
def test_load_dxt1() -> None:
with Image.open("Tests/images/ftex_dxt1.ftc") as im:
with Image.open("Tests/images/ftex_dxt1.png") as target:
assert_image_similar(im, target.convert("RGBA"), 15)


def test_invalid_file():
def test_invalid_file() -> None:
invalid_file = "Tests/images/flower.jpg"

with pytest.raises(SyntaxError):
Expand Down
Loading

0 comments on commit e7470ed

Please sign in to comment.