From 0256797d677794e4c8b2ad5d45ee19a23c72192a Mon Sep 17 00:00:00 2001 From: Nulano Date: Thu, 16 Nov 2023 00:04:36 +0100 Subject: [PATCH] use cibuildwheel on windows --- .github/workflows/wheels-test.cmd | 3 ++ .github/workflows/wheels.yml | 58 ++++++++++++++++++++++++++++++- pyproject.toml | 4 +++ winbuild/build_prepare.py | 3 ++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/wheels-test.cmd diff --git a/.github/workflows/wheels-test.cmd b/.github/workflows/wheels-test.cmd new file mode 100644 index 00000000000..7e135befe3c --- /dev/null +++ b/.github/workflows/wheels-test.cmd @@ -0,0 +1,3 @@ +echo TODO!!!! + + diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index d4bc4eb1b97..9f08b6c2444 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -5,12 +5,16 @@ on: paths: - ".github/workflows/wheels*.yml" - "wheels/*" + - "winbuild/build_prepare.py" + - "winbuild/fribidi.cmake" tags: - "*" pull_request: paths: - ".github/workflows/wheels*.yml" - "wheels/*" + - "winbuild/build_prepare.py" + - "winbuild/fribidi.cmake" workflow_dispatch: permissions: @@ -63,6 +67,58 @@ jobs: with: path: ./wheelhouse/*.whl + windows: + name: Windows ${{ matrix.arch }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - arch: x86 + cibw_arch: x86 + - arch: x64 + cibw_arch: AMD64 + - arch: ARM64 + cibw_arch: ARM64 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Checkout extra test images + uses: actions/checkout@v4 + with: + repository: python-pillow/test-images + path: Tests\test-images + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Install build dependencies + run: | + $nasm_uri = "https://github.com/python-pillow/pillow-depends/raw/main/nasm-2.16.01-win64.zip" + Invoke-WebRequest -Uri $nasm_uri -OutFile 'nasm.zip' + 7z x nasm.zip "-o$env:RUNNER_WORKSPACE\" + echo "$env:RUNNER_WORKSPACE\nasm-2.16.01" >> $env:GITHUB_PATH + + choco install ghostscript --version=10.0.0.20230317 + echo "C:\Program Files\gs\gs10.00.0\bin" >> $env:GITHUB_PATH + + # Install extra test images + xcopy /S /Y Tests\test-images\* Tests\images + + & python.exe winbuild\build_prepare.py -v --no-imagequant --architecture=${{ matrix.arch }} + shell: pwsh + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + with: + output-dir: wheelhouse + env: + CIBW_ARCHS: ${{ matrix.cibw_arch }} + CIBW_BEFORE_ALL: "call {package}\\winbuild\\build\\build_dep_all.cmd" + CIBW_CONFIG_SETTINGS: raqm=enable raqm=vendor fribidi=vendor + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + sdist: runs-on: ubuntu-latest steps: @@ -85,7 +141,7 @@ jobs: success: permissions: contents: none - needs: [build, sdist] + needs: [build, windows, sdist] runs-on: ubuntu-latest name: Wheels Successful steps: diff --git a/pyproject.toml b/pyproject.toml index 70572b99435..71719b1cf67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,10 @@ before-all = ".github/workflows/wheels-dependencies.sh" test-command = "cd {project} && .github/workflows/wheels-test.sh" test-extras = "tests" +[[tool.cibuildwheel.overrides]] +select = "*-win*" +test-command = "cd /d {project} && call .github/workflows/wheels-test.cmd" + [tool.ruff] line-length = 88 select = [ diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 7a5dd0a74bc..81970a2c55a 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -567,6 +567,9 @@ def build_dep(name: str) -> str: *get_footer(dep), ] + if "GITHUB_ACTIONS" in os.environ: + lines = [f"echo ::group::{banner}", *lines, "echo ::endgroup::"] + write_script(file, lines) return file