Skip to content
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
28 changes: 28 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,31 @@ jobs:
steps:
- name: Success
run: echo Windows Test Successful

docker:
runs-on: windows-2019
timeout-minutes: 45

name: Docker Python 3.7 x86

steps:
- uses: actions/checkout@v1

- uses: actions/checkout@v1
with:
repository: python-pillow/pillow-depends
ref: master

- name: Build system information
run: python .github/workflows/system-info.py

- name: Build Docker Image
run: |
# & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchWindowsEngine
echo "This step takes about 20 minutes, please be patient..."
docker build -m 2G -t python-pillow-build:latest winbuild\docker
shell: pwsh

- name: Run Docker
run: docker run --name PillowBuild -v ${env:GITHUB_WORKSPACE}:C:\Pillow -v ${env:RUNNER_WORKSPACE}\pillow-depends:C:\pillow-depends python-pillow-build C:\Pillow\winbuild\docker\build.cmd
shell: pwsh
13 changes: 13 additions & 0 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,19 @@ def is_win32():
return sys.platform.startswith("win32")


def is_win32_docker():
try:
import winreg

key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control"
)
winreg.QueryValueEx(key, "ContainerType") # fails if not in Docker container
return True
except (ImportError, OSError):
return False


def is_pypy():
return hasattr(sys, "pypy_translation_info")

Expand Down
3 changes: 2 additions & 1 deletion Tests/test_imagegrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

from PIL import Image, ImageGrab

from .helper import assert_image_equal_tofile, skip_unless_feature
from .helper import assert_image_equal_tofile, is_win32_docker, skip_unless_feature


class TestImageGrab:
@pytest.mark.skipif(
sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS"
)
@pytest.mark.skipif(is_win32_docker(), reason="running on headless Windows")
def test_grab(self):
ImageGrab.grab()
ImageGrab.grab(include_layered_windows=True)
Expand Down
40 changes: 40 additions & 0 deletions winbuild/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# escape=`

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

RUN powershell.exe -Command `
$ErrorActionPreference = 'Stop'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/win64/nasm-2.14.02-win64.zip -OutFile c:\nasm.zip ; `
Expand-Archive c:\nasm.zip -DestinationPath c:\

ARG PYTHON=3.7.3
ARG PYTHON_DIR=Python37
RUN powershell.exe -Command `
$ErrorActionPreference = 'Stop'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
wget https://www.python.org/ftp/python/%PYTHON%/python-%PYTHON%.exe -OutFile c:\python-%PYTHON%.exe ; `
Start-Process c:\python-%PYTHON%.exe -ArgumentList '/quiet TargetDir=c:\%PYTHON_DIR%\ InstallAllUsers=1 PrependPath=1' -Wait ; `
Remove-Item c:\python-%PYTHON%.exe -Force ; `
setx /M PYTHON C:\%PYTHON_DIR%

RUN C:\%PYTHON_DIR%\Scripts\pip.exe install pytest pytest-cov

# Default to PowerShell if no other command specified.
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\vs_buildtools.exe

# Install Build Tools excluding workloads and components with known issues.
RUN C:\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0

# Default to PowerShell if no other command specified.
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
18 changes: 18 additions & 0 deletions winbuild/docker/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

set CI=true
path C:\nasm-2.14.02\;%PATH%
xcopy /s c:\pillow-depends\test_images\* c:\pillow\tests\images

cd c:\pillow\winbuild\
c:\python37\python.exe build_prepare.py -v --depends=C:\pillow-depends
if errorlevel 1 echo Build prepare failed! && exit /B 1
call build\build_dep_all.cmd
if errorlevel 1 echo Build dependencies failed! && exit /B 1
call build\build_pillow.cmd install
if errorlevel 1 echo Build failed! && exit /B 1

cd c:\pillow
path c:\pillow\winbuild\build\bin;%PATH%
c:\python37\python.exe selftest.py --installed
if errorlevel 1 echo Selftest failed! && exit /B 1
c:\python37\python.exe -m pytest -vx -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests