Skip to content

Commit

Permalink
test cibuildwheel wheels in Docker on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Nov 26, 2023
1 parent 51953a2 commit 1086397
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 7 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,23 @@ jobs:
env:
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_BEFORE_ALL: "{package}\\winbuild\\build\\build_dep_all.cmd"
CIBW_CACHE_PATH: "C:\\cibw"
CIBW_TEST_SKIP: "*-win_arm64"
CIBW_TEST_COMMAND: >-
reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python.exe" /v "GlobalFlag" /t REG_SZ /d "0x02000000" /f &&
cd /d {project} &&
python.exe selftest.py &&
python.exe -m pytest -vx -W always Tests
docker run -it --rm
-v {project}:C:\pillow
-v C:\cibw:C:\cibw
-v %CD%\..\venv-test:%CD%\..\venv-test
-e CI -e GITHUB_ACTIONS
mcr.microsoft.com/windows/servercore:ltsc2022
cmd /v:on /c
call %CD%\..\venv-test\Scripts\activate.bat ^&^&
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python.exe" /v "GlobalFlag" /t REG_SZ /d "0x02000000" /f ^&^&
python --version ^&^&
cd /d C:\pillow ^&^&
path C:\pillow\winbuild\build\bin;!path! ^&^&
python selftest.py ^&^&
python -m pytest -vx -W always Tests Tests\check_wheel.py
shell: cmd
- uses: actions/upload-artifact@v3
with:
Expand Down
34 changes: 34 additions & 0 deletions Tests/check_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys

import pytest

from PIL import features


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_windows_wheel_modules():
expected_modules = ["pil", "freetype2", "littlecms2", "webp"]

assert features.get_supported_modules() == expected_modules


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_windows_wheel_codecs():
expected_codecs = ["jpg", "jpg_2000", "zlib", "libtiff"]

assert features.get_supported_codecs() == expected_codecs


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_windows_wheel_features():
expected_features = [
"webp_anim",
"webp_mux",
"transp_webp",
"raqm",
"fribidi",
"harfbuzz",
"libjpeg_turbo",
]

assert features.get_supported_features() == expected_features
13 changes: 11 additions & 2 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import os
import shutil
import subprocess
import sys
import sysconfig
import tempfile
Expand Down Expand Up @@ -258,11 +259,19 @@ def hopper(mode=None, cache={}):


def djpeg_available():
return bool(shutil.which("djpeg"))
try:
subprocess.check_call(["djpeg", "-version"])
return True
except subprocess.CalledProcessError:
return False


def cjpeg_available():
return bool(shutil.which("cjpeg"))
try:
subprocess.check_call(["cjpeg", "-version"])
return True
except subprocess.CalledProcessError:
return False


def netpbm_available():
Expand Down
2 changes: 2 additions & 0 deletions Tests/test_imagegrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class TestImageGrab:
sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS"
)
def test_grab(self):
if os.environ.get("USERNAME") == "ContainerAdministrator":
pytest.skip("can't grab screen when running in Docker")
ImageGrab.grab()
ImageGrab.grab(include_layered_windows=True)
ImageGrab.grab(all_screens=True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ version = {attr = "PIL.__version__"}

[tool.cibuildwheel]
before-all = ".github/workflows/wheels-dependencies.sh"
config-settings = "raqm=enable raqm=vendor fribidi=vendor"
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-extras = "tests"

Expand Down

0 comments on commit 1086397

Please sign in to comment.