Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check available features in Windows wheels #6847

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ jobs:
%pythonLocation%\python.exe -m pip wheel -v -C raqm=vendor -C fribidi=vendor -C imagequant=disable .
shell: cmd

- name: Test Wheel
if: "github.event_name != 'pull_request'"
run: |
docker run --rm -v ${env:GITHUB_WORKSPACE}:C:\pillow mcr.microsoft.com/windows/servercore:ltsc2022 powershell C:\pillow\winbuild\test_docker.ps1 ${{ matrix.python-version }}
shell: pwsh

- name: Upload wheel
uses: actions/upload-artifact@v3
if: "github.event_name != 'pull_request'"
Expand Down
24 changes: 24 additions & 0 deletions Tests/check_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys

import pytest

from PIL import features


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_windows_wheel_features():
expected_modules = ["pil", "tkinter", "freetype2", "littlecms2", "webp"]
expected_codecs = ["jpg", "jpg_2000", "zlib", "libtiff"]
expected_features = [
"webp_anim",
"webp_mux",
"transp_webp",
"raqm",
"fribidi",
"harfbuzz",
"libjpeg_turbo",
]

assert features.get_supported_modules() == expected_modules
assert features.get_supported_codecs() == expected_codecs
assert features.get_supported_features() == expected_features
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 @@
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")

Check warning on line 19 in Tests/test_imagegrab.py

View check run for this annotation

Codecov / codecov/patch

Tests/test_imagegrab.py#L19

Added line #L19 was not covered by tests
ImageGrab.grab()
ImageGrab.grab(include_layered_windows=True)
ImageGrab.grab(all_screens=True)
Expand Down
38 changes: 38 additions & 0 deletions winbuild/test_docker.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
param ([string]$python)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if ($python -like "pypy*") {
echo "Downloading https://aka.ms/vs/15/release/vc_redist.x64.exe"
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
$url = 'https://downloads.python.org/pypy/{0}-v7.3.13-win64.zip' -f $python
echo "Downloading $url"
Invoke-WebRequest -Uri $url -OutFile 'pypy.zip'
tar -xf 'pypy.zip'
mv pypy*-win64 C:\Python
} else {
$url = 'https://www.python.org/ftp/python/{0}.0/python-{0}.0-amd64.exe' -f $python
echo "Downloading $url"
Invoke-WebRequest -Uri $url -OutFile 'setup.exe'
Start-Process setup.exe -Wait -NoNewWindow -PassThru -ArgumentList @(
'/quiet',
'InstallAllUsers=0',
'TargetDir=C:\Python',
'PrependPath=1',
'Shortcuts=0',
'Include_doc=0',
'Include_pip=1',
'Include_test=0'
)
}
$env:CI = "true"
$env:path += ";C:\Python\;C:\pillow\winbuild\build\bin\"
cd C:\pillow
& python -VV
& python -m ensurepip
& python -m pip install -U pip
& python -m pip install pytest pytest-timeout
& python -m pip install "$(Get-ChildItem *.whl -Name)"
& python -m pytest -vx Tests\check_wheel.py Tests
if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }