mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
test cibuildwheel wheels in Docker on Windows
This commit is contained in:
parent
3d49244d36
commit
1fdb0668d8
22
.github/workflows/wheels-test.ps1
vendored
Normal file
22
.github/workflows/wheels-test.ps1
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
param ([string]$venv, [string]$pillow="C:\pillow")
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
Set-PSDebug -Trace 1
|
||||||
|
if ("$venv" -like "*\cibw-run-*\pp*-win_amd64\*") {
|
||||||
|
# unlike CPython, PyPy requires Visual C++ Redistributable to be installed
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
Invoke-WebRequest -Uri 'https://aka.ms/vs/15/release/vc_redist.x64.exe' -OutFile 'vc_redist.x64.exe'
|
||||||
|
C:\vc_redist.x64.exe /install /quiet /norestart | Out-Null
|
||||||
|
}
|
||||||
|
$env:path += ";$pillow\winbuild\build\bin\"
|
||||||
|
& "$venv\Scripts\activate.ps1"
|
||||||
|
& reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\python.exe" /v "GlobalFlag" /t REG_SZ /d "0x02000000" /f
|
||||||
|
cd $pillow
|
||||||
|
& python -VV
|
||||||
|
if (!$?) { exit $LASTEXITCODE }
|
||||||
|
& python selftest.py
|
||||||
|
if (!$?) { exit $LASTEXITCODE }
|
||||||
|
& python -m pytest -vx Tests\check_wheel.py
|
||||||
|
if (!$?) { exit $LASTEXITCODE }
|
||||||
|
& python -m pytest -vx Tests
|
||||||
|
if (!$?) { exit $LASTEXITCODE }
|
22
.github/workflows/wheels-test.sh
vendored
22
.github/workflows/wheels-test.sh
vendored
|
@ -1,10 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
EXP_CODECS="jpg jpg_2000 libtiff zlib"
|
|
||||||
EXP_MODULES="freetype2 littlecms2 pil tkinter webp"
|
|
||||||
EXP_FEATURES="fribidi harfbuzz libjpeg_turbo raqm transp_webp webp_anim webp_mux xcb"
|
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
brew install fribidi
|
brew install fribidi
|
||||||
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
|
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
|
||||||
|
@ -25,21 +21,5 @@ fi
|
||||||
|
|
||||||
# Runs tests
|
# Runs tests
|
||||||
python3 selftest.py
|
python3 selftest.py
|
||||||
|
python3 -m pytest Tests/check_wheel.py
|
||||||
python3 -m pytest
|
python3 -m pytest
|
||||||
|
|
||||||
# Test against expected codecs, modules and features
|
|
||||||
codecs=$(python3 -c 'from PIL.features import *; print(" ".join(sorted(get_supported_codecs())))')
|
|
||||||
if [ "$codecs" != "$EXP_CODECS" ]; then
|
|
||||||
echo "Codecs should be: '$EXP_CODECS'; but are '$codecs'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
modules=$(python3 -c 'from PIL.features import *; print(" ".join(sorted(get_supported_modules())))')
|
|
||||||
if [ "$modules" != "$EXP_MODULES" ]; then
|
|
||||||
echo "Modules should be: '$EXP_MODULES'; but are '$modules'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
features=$(python3 -c 'from PIL.features import *; print(" ".join(sorted(get_supported_features())))')
|
|
||||||
if [ "$features" != "$EXP_FEATURES" ]; then
|
|
||||||
echo "Features should be: '$EXP_FEATURES'; but are '$features'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
12
.github/workflows/wheels.yml
vendored
12
.github/workflows/wheels.yml
vendored
|
@ -148,12 +148,16 @@ jobs:
|
||||||
env:
|
env:
|
||||||
CIBW_ARCHS: ${{ matrix.cibw_arch }}
|
CIBW_ARCHS: ${{ matrix.cibw_arch }}
|
||||||
CIBW_BEFORE_ALL: "{package}\\winbuild\\build\\build_dep_all.cmd"
|
CIBW_BEFORE_ALL: "{package}\\winbuild\\build\\build_dep_all.cmd"
|
||||||
|
CIBW_CACHE_PATH: "C:\\cibw"
|
||||||
CIBW_TEST_SKIP: "*-win_arm64"
|
CIBW_TEST_SKIP: "*-win_arm64"
|
||||||
CIBW_TEST_COMMAND: >-
|
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 &&
|
docker run --rm
|
||||||
cd /d {project} &&
|
-v {project}:C:\pillow
|
||||||
python.exe selftest.py &&
|
-v C:\cibw:C:\cibw
|
||||||
python.exe -m pytest -vx -W always Tests
|
-v %CD%\..\venv-test:%CD%\..\venv-test
|
||||||
|
-e CI -e GITHUB_ACTIONS
|
||||||
|
mcr.microsoft.com/windows/servercore:ltsc2022
|
||||||
|
powershell C:\pillow\.github\workflows\wheels-test.ps1 %CD%\..\venv-test
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
|
38
Tests/check_wheel.py
Normal file
38
Tests/check_wheel.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import importlib.util
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from PIL import features
|
||||||
|
|
||||||
|
|
||||||
|
def test_wheel_modules():
|
||||||
|
expected_modules = {"pil", "tkinter", "freetype2", "littlecms2", "webp"}
|
||||||
|
|
||||||
|
# tkinter is not available in cibuildwheel installed CPython on Windows
|
||||||
|
if not importlib.util.find_spec("tkinter"):
|
||||||
|
expected_modules.remove("tkinter")
|
||||||
|
|
||||||
|
assert set(features.get_supported_modules()) == expected_modules
|
||||||
|
|
||||||
|
|
||||||
|
def test_wheel_codecs():
|
||||||
|
expected_codecs = {"jpg", "jpg_2000", "zlib", "libtiff"}
|
||||||
|
|
||||||
|
assert set(features.get_supported_codecs()) == expected_codecs
|
||||||
|
|
||||||
|
|
||||||
|
def test_wheel_features():
|
||||||
|
expected_features = {
|
||||||
|
"webp_anim",
|
||||||
|
"webp_mux",
|
||||||
|
"transp_webp",
|
||||||
|
"raqm",
|
||||||
|
"fribidi",
|
||||||
|
"harfbuzz",
|
||||||
|
"libjpeg_turbo",
|
||||||
|
"xcb",
|
||||||
|
}
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
expected_features.remove("xcb")
|
||||||
|
|
||||||
|
assert set(features.get_supported_features()) == expected_features
|
|
@ -5,6 +5,7 @@ Helper functions.
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -258,11 +259,21 @@ def hopper(mode=None, cache={}):
|
||||||
|
|
||||||
|
|
||||||
def djpeg_available():
|
def djpeg_available():
|
||||||
return bool(shutil.which("djpeg"))
|
if shutil.which("djpeg"):
|
||||||
|
try:
|
||||||
|
subprocess.check_call(["djpeg", "-version"])
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def cjpeg_available():
|
def cjpeg_available():
|
||||||
return bool(shutil.which("cjpeg"))
|
if shutil.which("cjpeg"):
|
||||||
|
try:
|
||||||
|
subprocess.check_call(["cjpeg", "-version"])
|
||||||
|
return True
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def netpbm_available():
|
def netpbm_available():
|
||||||
|
|
|
@ -15,6 +15,8 @@ class TestImageGrab:
|
||||||
sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS"
|
sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS"
|
||||||
)
|
)
|
||||||
def test_grab(self):
|
def test_grab(self):
|
||||||
|
if os.environ.get("USERNAME") == "ContainerAdministrator":
|
||||||
|
pytest.skip("can't grab screen when running in Docker")
|
||||||
ImageGrab.grab()
|
ImageGrab.grab()
|
||||||
ImageGrab.grab(include_layered_windows=True)
|
ImageGrab.grab(include_layered_windows=True)
|
||||||
ImageGrab.grab(all_screens=True)
|
ImageGrab.grab(all_screens=True)
|
||||||
|
|
|
@ -88,7 +88,7 @@ version = {attr = "PIL.__version__"}
|
||||||
|
|
||||||
[tool.cibuildwheel]
|
[tool.cibuildwheel]
|
||||||
before-all = ".github/workflows/wheels-dependencies.sh"
|
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-command = "cd {project} && .github/workflows/wheels-test.sh"
|
||||||
test-extras = "tests"
|
test-extras = "tests"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user