From ad7fee5ed0f78dc87f805c381c8070d313f55f0a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 14 Nov 2023 23:23:46 +1100 Subject: [PATCH 01/13] Use cibuildwheel --- .github/workflows/wheels-build.sh | 40 ------ .../workflows/wheels-dependencies.sh | 112 ++++++----------- .github/workflows/wheels-linux.yml | 69 ----------- .github/workflows/wheels-macos.yml | 57 --------- .github/workflows/wheels-test.sh | 45 +++++++ .github/workflows/wheels.yml | 52 ++++++-- .travis.yml | 117 ++---------------- pyproject.toml | 8 ++ 8 files changed, 147 insertions(+), 353 deletions(-) delete mode 100755 .github/workflows/wheels-build.sh rename wheels/config.sh => .github/workflows/wheels-dependencies.sh (54%) mode change 100644 => 100755 delete mode 100644 .github/workflows/wheels-linux.yml delete mode 100644 .github/workflows/wheels-macos.yml create mode 100755 .github/workflows/wheels-test.sh diff --git a/.github/workflows/wheels-build.sh b/.github/workflows/wheels-build.sh deleted file mode 100755 index 0aeec6b96..000000000 --- a/.github/workflows/wheels-build.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - # webp, zstd, xz, libtiff, libxcb cause a conflict with building webp, libtiff, libxcb - # libxdmcp causes an issue on macOS < 11 - # curl from brew requires zstd, use system curl - # if php is installed, brew tries to reinstall these after installing openblas - # remove lcms2 and libpng to fix building openjpeg on arm64 - brew remove --ignore-dependencies webp zstd xz libpng libtiff libxcb libxdmcp curl php lcms2 ghostscript - - brew install pkg-config - - if [[ "$PLAT" == "arm64" ]]; then - export MACOSX_DEPLOYMENT_TARGET="11.0" - else - export MACOSX_DEPLOYMENT_TARGET="10.10" - fi -fi - -if [[ "$MB_PYTHON_VERSION" == pypy3* ]]; then - MB_PYTHON_OSX_VER="10.9" -fi - -echo "::group::Install a virtualenv" - source wheels/multibuild/common_utils.sh - source wheels/multibuild/travis_steps.sh - python3 -m pip install virtualenv - before_install -echo "::endgroup::" - -echo "::group::Build wheel" - build_wheel - ls -l "${GITHUB_WORKSPACE}/${WHEEL_SDIR}/" -echo "::endgroup::" - -if [[ $MACOSX_DEPLOYMENT_TARGET != "11.0" ]]; then - echo "::group::Test wheel" - install_run - echo "::endgroup::" -fi diff --git a/wheels/config.sh b/.github/workflows/wheels-dependencies.sh old mode 100644 new mode 100755 similarity index 54% rename from wheels/config.sh rename to .github/workflows/wheels-dependencies.sh index 655ea295b..3cd454ba2 --- a/wheels/config.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -1,5 +1,16 @@ +#!/bin/bash # Define custom utilities # Test for macOS with [ -n "$IS_MACOS" ] +if [ -z "$IS_MACOS" ]; then + export MB_ML_LIBC=${AUDITWHEEL_POLICY::9} + export MB_ML_VER=${AUDITWHEEL_POLICY:9} +fi +export PLAT=$CIBW_ARCHS +source wheels/multibuild/common_utils.sh +source wheels/multibuild/library_builders.sh +if [ -z "$IS_MACOS" ]; then + source wheels/multibuild/manylinux_utils.sh +fi ARCHIVE_SDIR=pillow-depends-main @@ -27,9 +38,9 @@ BZIP2_VERSION=1.0.8 LIBXCB_VERSION=1.16 BROTLI_VERSION=1.1.0 -if [[ -n "$IS_MACOS" ]] && [[ "$PLAT" == "x86_64" ]]; then +if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "x86_64" ]]; then function build_openjpeg { - local out_dir=$(fetch_unpack https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz) + local out_dir=$(fetch_unpack https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz openjpeg-2.5.0.tar.gz) (cd $out_dir \ && cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \ && make install) @@ -39,7 +50,7 @@ fi function build_brotli { local cmake=$(get_modern_cmake) - local out_dir=$(fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz) + local out_dir=$(fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz brotli-1.1.0.tar.gz) (cd $out_dir \ && $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \ && make install) @@ -49,12 +60,7 @@ function build_brotli { fi } -function pre_build { - # Any stuff that you need to do before you start building the wheels - # Runs in the root directory of this repository. - curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip - untar pillow-depends-main.zip - +function build { build_xz if [ -z "$IS_ALPINE" ] && [ -z "$IS_MACOS" ]; then yum remove -y zlib-devel @@ -114,74 +120,36 @@ function pre_build { fi build_simple harfbuzz $HARFBUZZ_VERSION https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION tar.xz --with-freetype=yes --with-glib=no if [ -z "$IS_MACOS" ]; then - export FREETYPE_LIBS='' - export FREETYPE_CFLAGS='' + export FREETYPE_LIBS="" + export FREETYPE_CFLAGS="" fi - - # Append licenses - for filename in wheels/dependency_licenses/*; do - echo -e "\n\n----\n\n$(basename $filename | cut -f 1 -d '.')\n" | cat >> LICENSE - cat $filename >> LICENSE - done } -function pip_wheel_cmd { - local abs_wheelhouse=$1 - if [ -z "$IS_MACOS" ]; then - CFLAGS="$CFLAGS --std=c99" # for Raqm - fi - python3 -m pip wheel $(pip_opts) \ - -C raqm=enable -C raqm=vendor -C fribidi=vendor \ - -w $abs_wheelhouse --no-deps . -} +# Any stuff that you need to do before you start building the wheels +# Runs in the root directory of this repository. +curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip +untar pillow-depends-main.zip -function run_tests_in_repo { - # Run Pillow tests from within source repo - python3 selftest.py - python3 -m pytest -} +if [[ -n "$IS_MACOS" ]]; then + # webp, zstd, xz, libtiff, libxcb cause a conflict with building webp, libtiff, libxcb + # libxdmcp causes an issue on macOS < 11 + # curl from brew requires zstd, use system curl + # if php is installed, brew tries to reinstall these after installing openblas + # remove cairo to fix building harfbuzz on arm64 + # remove lcms2 and libpng to fix building openjpeg on arm64 + brew remove --ignore-dependencies webp zstd xz libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript -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" + brew install pkg-config -function run_tests { - if [ -n "$IS_MACOS" ]; then - brew install fribidi - export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig" - elif [ -n "$IS_ALPINE" ]; then - apk add curl fribidi - else - apt-get update - apt-get install -y curl libfribidi0 libopenblas-dev pkg-config unzip - fi - if [ -z "$IS_ALPINE" ]; then - python3 -m pip install numpy - fi - python3 -m pip install defusedxml olefile pyroma + if [[ "$CIBW_ARCHS" != "arm64" ]]; then + export MACOSX_DEPLOYMENT_TARGET="10.10" + fi +fi - curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip - untar pillow-test-images.zip - mv test-images-main/* ../Tests/images +wrap_wheel_builder build - # Runs tests on installed distribution from an empty directory - (cd .. && run_tests_in_repo) - # Test against expected codecs, modules and features - local ret=0 - local 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'" - ret=1 - fi - local 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'" - ret=1 - fi - local 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'" - ret=1 - fi - return $ret -} +# Append licenses +for filename in wheels/dependency_licenses/*; do + echo -e "\n\n----\n\n$(basename $filename | cut -f 1 -d '.')\n" | cat >> LICENSE + cat $filename >> LICENSE +done diff --git a/.github/workflows/wheels-linux.yml b/.github/workflows/wheels-linux.yml deleted file mode 100644 index 8b2d9d451..000000000 --- a/.github/workflows/wheels-linux.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Build Linux wheels - -on: - workflow_call: - inputs: - artifacts-name: - required: true - type: string - -env: - CONFIG_PATH: "wheels/config.sh" - REPO_DIR: "." - TEST_DEPENDS: "pytest pytest-timeout" - -jobs: - build: - name: ${{ matrix.python }} ${{ matrix.mb-ml-libc }}${{ matrix.mb-ml-ver }} - runs-on: "ubuntu-latest" - strategy: - fail-fast: false - matrix: - python: [ - "pypy3.9-7.3.13", - "pypy3.10-7.3.13", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - ] - mb-ml-libc: [ "manylinux" ] - mb-ml-ver: [ 2014, "_2_28" ] - include: - - python: "3.8" - mb-ml-libc: "musllinux" - mb-ml-ver: "_1_1" - - python: "3.9" - mb-ml-libc: "musllinux" - mb-ml-ver: "_1_1" - - python: "3.10" - mb-ml-libc: "musllinux" - mb-ml-ver: "_1_1" - - python: "3.11" - mb-ml-libc: "musllinux" - mb-ml-ver: "_1_1" - - python: "3.12" - mb-ml-libc: "musllinux" - mb-ml-ver: "_1_1" - env: - MB_PYTHON_VERSION: ${{ matrix.python }} - MB_ML_LIBC: ${{ matrix.mb-ml-libc }} - MB_ML_VER: ${{ matrix.mb-ml-ver }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - name: Build Wheel - run: .github/workflows/wheels-build.sh - - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.artifacts-name }} - path: wheelhouse/*.whl - # Uncomment to get SSH access for testing - # - name: Setup tmate session - # if: failure() - # uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/wheels-macos.yml b/.github/workflows/wheels-macos.yml deleted file mode 100644 index c51abf39a..000000000 --- a/.github/workflows/wheels-macos.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Build macOS wheels - -on: - workflow_call: - inputs: - artifacts-name: - required: true - type: string - -env: - CONFIG_PATH: "wheels/config.sh" - REPO_DIR: "." - TEST_DEPENDS: "pytest pytest-timeout" - -jobs: - build: - name: ${{ matrix.python }} ${{ matrix.platform }} - runs-on: "macos-latest" - strategy: - fail-fast: false - matrix: - python: [ - "pypy3.9-7.3.13", - "pypy3.10-7.3.13", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - ] - platform: [ "x86_64", "arm64" ] - exclude: - - python: "pypy3.9-7.3.13" - platform: "arm64" - - python: "pypy3.10-7.3.13" - platform: "arm64" - env: - PLAT: ${{ matrix.platform }} - MB_PYTHON_VERSION: ${{ matrix.python }} - TRAVIS_OS_NAME: "osx" - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - name: Build Wheel - run: .github/workflows/wheels-build.sh - - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.artifacts-name }} - path: wheelhouse/*.whl - # Uncomment to get SSH access for testing - # - name: Setup tmate session - # if: failure() - # uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/wheels-test.sh b/.github/workflows/wheels-test.sh new file mode 100755 index 000000000..ab8de3dc9 --- /dev/null +++ b/.github/workflows/wheels-test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +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 + brew install fribidi + export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig" +elif [ "${AUDITWHEEL_POLICY:9}" == "musllinux" ]; then + apk add curl fribidi +else + yum install -y fribidi openblas-devel pkgconfig +fi +if [ "${AUDITWHEEL_POLICY:9}" != "musllinux" ]; then + python3 -m pip install numpy +fi + +if [ ! -d "test-images-main" ]; then + curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip + unzip pillow-test-images.zip + mv test-images-main/* Tests/images +fi + +# Runs tests +python3 selftest.py +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 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index bcffe6839..475019c12 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -24,15 +24,47 @@ env: FORCE_COLOR: 1 jobs: - macos: - uses: ./.github/workflows/wheels-macos.yml - with: - artifacts-name: "dist" - - linux: - uses: ./.github/workflows/wheels-linux.yml - with: - artifacts-name: "dist" + build: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - name: "macOS x86_64" + os: macos-latest + archs: x86_64 + - name: "macOS arm64" + os: macos-latest + archs: arm64 + - name: "manylinux2014 and musllinux x86_64" + os: ubuntu-latest + archs: x86_64 + - name: "manylinux_2_28 x86_64" + os: ubuntu-latest + archs: x86_64 + build: "*manylinux*" + manylinux: "manylinux_2_28" + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Build wheels + run: | + python3 -m pip install cibuildwheel + python3 -m cibuildwheel --output-dir wheelhouse + env: + CIBW_ARCHS: ${{ matrix.archs }} + CIBW_BUILD: ${{ matrix.build }} + CIBW_CONFIG_SETTINGS: raqm=enable raqm=vendor fribidi=vendor + CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }} + CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl sdist: runs-on: ubuntu-latest @@ -56,7 +88,7 @@ jobs: success: permissions: contents: none - needs: [macos, linux, sdist] + needs: [build, sdist] runs-on: ubuntu-latest name: Wheels Successful steps: diff --git a/.travis.yml b/.travis.yml index 503f243e6..d8add1b6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,7 @@ if: tag IS present OR type = api env: global: - - CONFIG_PATH=wheels/config.sh - - REPO_DIR=. - - PLAT=aarch64 - - TEST_DEPENDS=pytest-timeout + - CIBW_ARCHS=aarch64 language: python # Default Python version is usually 3.6 @@ -15,120 +12,30 @@ services: docker jobs: include: - - name: "3.8 Focal manylinux2014 aarch64" + - name: "manylinux2014 and musllinux aarch64" + os: linux + arch: arm64 + - name: "manylinux_2_28 aarch64" os: linux arch: arm64 env: - - MB_ML_VER=2014 - - MB_PYTHON_VERSION=3.8 - - name: "3.8 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_2_28" - - MB_PYTHON_VERSION=3.8 - - name: "3.8 musllinux_1_1 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_1_1" - - MB_ML_LIBC="musllinux" - - MB_PYTHON_VERSION=3.8 - - name: "3.9 Focal manylinux2014 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER=2014 - - MB_PYTHON_VERSION=3.9 - - name: "3.9 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_2_28" - - MB_PYTHON_VERSION=3.9 - - name: "3.9 musllinux_1_1 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_1_1" - - MB_ML_LIBC="musllinux" - - MB_PYTHON_VERSION=3.9 - - name: "3.10 Focal manylinux2014 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER=2014 - - MB_PYTHON_VERSION=3.10 - - name: "3.10 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_2_28" - - MB_PYTHON_VERSION=3.10 - - name: "3.10 musllinux_1_1 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_1_1" - - MB_ML_LIBC="musllinux" - - MB_PYTHON_VERSION=3.10 - - name: "3.11 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER=2014 - - MB_PYTHON_VERSION=3.11 - - name: "3.11 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_2_28" - - MB_PYTHON_VERSION=3.11 - - name: "3.11 musllinux_1_1 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_1_1" - - MB_ML_LIBC="musllinux" - - MB_PYTHON_VERSION=3.11 - - name: "3.12 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER=2014 - - MB_PYTHON_VERSION=3.12 - - name: "3.12 Focal manylinux_2_28 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_2_28" - - MB_PYTHON_VERSION=3.12 - - name: "3.12 musllinux_1_1 aarch64" - os: linux - arch: arm64 - env: - - MB_ML_VER="_1_1" - - MB_ML_LIBC="musllinux" - - MB_PYTHON_VERSION=3.12 - -before_install: - - source wheels/multibuild/common_utils.sh - - source wheels/multibuild/travis_steps.sh - - before_install + - CIBW_BUILD: "*manylinux*" + - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28" + - CIBW_MANYLINUX_PYPY_X86_64_IMAGE: "manylinux_2_28" install: - - build_multilinux aarch64 build_wheel - - ls -l "${TRAVIS_BUILD_DIR}/${WHEEL_SDIR}/" + - python3 -m pip install cibuildwheel script: - - install_run + - python3 -m cibuildwheel --output-dir wheelhouse + - ls -l "${TRAVIS_BUILD_DIR}/wheelhouse/" # Upload wheels to GitHub Releases deploy: provider: releases api_key: $GITHUB_RELEASE_TOKEN file_glob: true - file: "${TRAVIS_BUILD_DIR}/${WHEEL_SDIR}/*.whl" + file: "${TRAVIS_BUILD_DIR}/wheelhouse/*.whl" on: repo: python-pillow/Pillow tags: true diff --git a/pyproject.toml b/pyproject.toml index a49179a37..ba11096fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,14 @@ package-dir = {"" = "src"} [tool.setuptools.dynamic] version = {attr = "PIL.__version__"} +[tool.cibuildwheel] +before-all = ".github/workflows/wheels-dependencies.sh" +test-command = "cd {project} && .github/workflows/wheels-test.sh" +test-extras = "tests" + +[tool.cibuildwheel.linux] +environment = { CFLAGS="--std=c99" } + [tool.ruff] line-length = 88 select = [ From 9be181c2bf2c51072d9210eadc41a90a194fb11d Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:48:10 +1100 Subject: [PATCH 02/13] Use action Co-authored-by: Hugo van Kemenade --- .github/workflows/wheels.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 475019c12..d4bc4eb1b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -49,13 +49,10 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v4 - with: - python-version: "3.x" - name: Build wheels - run: | - python3 -m pip install cibuildwheel - python3 -m cibuildwheel --output-dir wheelhouse + uses: pypa/cibuildwheel@v2.16.2 + with: + output-dir: wheelhouse env: CIBW_ARCHS: ${{ matrix.archs }} CIBW_BUILD: ${{ matrix.build }} From 0a12f6c39950217cd4a56ccb78840dd763c40027 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 15 Nov 2023 13:21:38 +1100 Subject: [PATCH 03/13] Removed --std=c99 setting --- .github/workflows/wheels-test.sh | 4 ++-- pyproject.toml | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels-test.sh b/.github/workflows/wheels-test.sh index ab8de3dc9..f2c74dcd4 100755 --- a/.github/workflows/wheels-test.sh +++ b/.github/workflows/wheels-test.sh @@ -8,12 +8,12 @@ EXP_FEATURES="fribidi harfbuzz libjpeg_turbo raqm transp_webp webp_anim webp_mux if [[ "$OSTYPE" == "darwin"* ]]; then brew install fribidi export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig" -elif [ "${AUDITWHEEL_POLICY:9}" == "musllinux" ]; then +elif [ "${AUDITWHEEL_POLICY::9}" == "musllinux" ]; then apk add curl fribidi else yum install -y fribidi openblas-devel pkgconfig fi -if [ "${AUDITWHEEL_POLICY:9}" != "musllinux" ]; then +if [ "${AUDITWHEEL_POLICY::9}" != "musllinux" ]; then python3 -m pip install numpy fi diff --git a/pyproject.toml b/pyproject.toml index ba11096fa..70572b994 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,9 +82,6 @@ before-all = ".github/workflows/wheels-dependencies.sh" test-command = "cd {project} && .github/workflows/wheels-test.sh" test-extras = "tests" -[tool.cibuildwheel.linux] -environment = { CFLAGS="--std=c99" } - [tool.ruff] line-length = 88 select = [ From 6672663c093467643e05aa1d880b5c228677f166 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 15 Nov 2023 15:47:24 +1100 Subject: [PATCH 04/13] Pin cibuildwheel version --- .travis.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8add1b6f..f75a044ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ if: tag IS present OR type = api env: global: - CIBW_ARCHS=aarch64 + - CIBW_CONFIG_SETTINGS="raqm=enable raqm=vendor fribidi=vendor" language: python # Default Python version is usually 3.6 @@ -12,19 +13,28 @@ services: docker jobs: include: - - name: "manylinux2014 and musllinux aarch64" + - name: "manylinux2014 aarch64" os: linux arch: arm64 + env: + - CIBW_BUILD="*manylinux*" + - CIBW_MANYLINUX_AARCH64_IMAGE=manylinux2014 + - CIBW_MANYLINUX_PYPY_AARCH64_IMAGE=manylinux2014 - name: "manylinux_2_28 aarch64" os: linux arch: arm64 env: - - CIBW_BUILD: "*manylinux*" - - CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28" - - CIBW_MANYLINUX_PYPY_X86_64_IMAGE: "manylinux_2_28" + - CIBW_BUILD="*manylinux*" + - CIBW_MANYLINUX_AARCH64_IMAGE=manylinux_2_28 + - CIBW_MANYLINUX_PYPY_AARCH64_IMAGE=manylinux_2_28 + - name: "musllinux aarch64" + os: linux + arch: arm64 + env: + - CIBW_BUILD="*musllinux*" install: - - python3 -m pip install cibuildwheel + - python3 -m pip install cibuildwheel==2.16.2 script: - python3 -m cibuildwheel --output-dir wheelhouse From 0204e70e7bd831ee0faf923703e3e7faec7666a6 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 15 Nov 2023 14:09:34 +1100 Subject: [PATCH 05/13] Removed openblas-devel and pkgconfig on manylinux --- .github/workflows/wheels-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels-test.sh b/.github/workflows/wheels-test.sh index f2c74dcd4..34dfeaf14 100755 --- a/.github/workflows/wheels-test.sh +++ b/.github/workflows/wheels-test.sh @@ -11,7 +11,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then elif [ "${AUDITWHEEL_POLICY::9}" == "musllinux" ]; then apk add curl fribidi else - yum install -y fribidi openblas-devel pkgconfig + yum install -y fribidi fi if [ "${AUDITWHEEL_POLICY::9}" != "musllinux" ]; then python3 -m pip install numpy From 9f1a1d3fc81e0f37961b389e2e6ec13514fb53af Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 16 Nov 2023 08:13:08 +1100 Subject: [PATCH 06/13] Fixed xcb setup --- .github/workflows/wheels-dependencies.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh index 3cd454ba2..a5a3aa973 100755 --- a/.github/workflows/wheels-dependencies.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -67,7 +67,7 @@ function build { fi build_new_zlib - if [ -n "$IS_MACOS" ]; then + if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then ORIGINAL_BUILD_PREFIX=$BUILD_PREFIX ORIGINAL_PKG_CONFIG_PATH=$PKG_CONFIG_PATH BUILD_PREFIX=`dirname $(dirname $(which python))` @@ -75,15 +75,19 @@ function build { fi build_simple xcb-proto 1.16.0 https://xorg.freedesktop.org/archive/individual/proto if [ -n "$IS_MACOS" ]; then - build_simple xorgproto 2023.2 https://www.x.org/pub/individual/proto - build_simple libXau 1.0.11 https://www.x.org/pub/individual/lib - build_simple libpthread-stubs 0.5 https://xcb.freedesktop.org/dist - cp venv/share/pkgconfig/xcb-proto.pc venv/lib/pkgconfig/xcb-proto.pc + if [[ "$CIBW_ARCHS" == "arm64" ]]; then + build_simple xorgproto 2023.2 https://www.x.org/pub/individual/proto + build_simple libXau 1.0.11 https://www.x.org/pub/individual/lib + build_simple libpthread-stubs 0.5 https://xcb.freedesktop.org/dist + if [ -f /Library/Frameworks/Python.framework/Versions/Current/share/pkgconfig/xcb-proto.pc ]; then + cp /Library/Frameworks/Python.framework/Versions/Current/share/pkgconfig/xcb-proto.pc /Library/Frameworks/Python.framework/Versions/Current/lib/pkgconfig/xcb-proto.pc + fi + fi else sed s/\${pc_sysrootdir\}// /usr/local/share/pkgconfig/xcb-proto.pc > /usr/local/lib/pkgconfig/xcb-proto.pc fi build_simple libxcb $LIBXCB_VERSION https://www.x.org/releases/individual/lib - if [ -n "$IS_MACOS" ]; then + if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then BUILD_PREFIX=$ORIGINAL_BUILD_PREFIX PKG_CONFIG_PATH=$ORIGINAL_PKG_CONFIG_PATH fi From d077190cce957918f7e4ebcef8c4a2e6ae57407b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 16 Nov 2023 08:32:34 +1100 Subject: [PATCH 07/13] Skip tests on macOS arm64 --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index d4bc4eb1b..0e81254ac 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -59,6 +59,7 @@ jobs: CIBW_CONFIG_SETTINGS: raqm=enable raqm=vendor fribidi=vendor CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} + CIBW_TEST_SKIP: "*-macosx_arm64" - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl From 3b1e46ef667afcdb17f1afb68f55510351b4748b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 16 Nov 2023 09:10:44 +1100 Subject: [PATCH 08/13] Move wheels into dist.zip --- .github/workflows/wheels.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0e81254ac..6bb23a250 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -49,6 +49,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - name: Build wheels uses: pypa/cibuildwheel@v2.16.2 with: @@ -60,8 +61,10 @@ jobs: CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_TEST_SKIP: "*-macosx_arm64" + - uses: actions/upload-artifact@v3 with: + name: dist path: ./wheelhouse/*.whl sdist: From e013ad96213fe566411ad2655b3072428574deb9 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 16 Nov 2023 09:22:23 +1100 Subject: [PATCH 09/13] Restored MACOSX_DEPLOYMENT_TARGET on x86_64 --- .github/workflows/wheels-dependencies.sh | 4 ---- .github/workflows/wheels.yml | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh index a5a3aa973..410941c6e 100755 --- a/.github/workflows/wheels-dependencies.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -144,10 +144,6 @@ if [[ -n "$IS_MACOS" ]]; then brew remove --ignore-dependencies webp zstd xz libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript brew install pkg-config - - if [[ "$CIBW_ARCHS" != "arm64" ]]; then - export MACOSX_DEPLOYMENT_TARGET="10.10" - fi fi wrap_wheel_builder build diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6bb23a250..89b1c7b6a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -34,9 +34,11 @@ jobs: - name: "macOS x86_64" os: macos-latest archs: x86_64 + macosx_deployment_target: "10.10" - name: "macOS arm64" os: macos-latest archs: arm64 + macosx_deployment_target: "11.0" - name: "manylinux2014 and musllinux x86_64" os: ubuntu-latest archs: x86_64 @@ -61,6 +63,7 @@ jobs: CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_TEST_SKIP: "*-macosx_arm64" + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }} - uses: actions/upload-artifact@v3 with: From c42ebf7e8e69bc4f51b1a3ff61a5f35f415b6b3d Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:32:52 +1100 Subject: [PATCH 10/13] Skip PyPy 3.8 Co-authored-by: Hugo van Kemenade --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 89b1c7b6a..8e73fe375 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -62,6 +62,7 @@ jobs: CIBW_CONFIG_SETTINGS: raqm=enable raqm=vendor fribidi=vendor CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }} CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }} + CIBW_SKIP: pp38-* CIBW_TEST_SKIP: "*-macosx_arm64" MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }} From d4a70161572d053347762a0c759dbfff9dae1c0b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 16 Nov 2023 10:10:10 +1100 Subject: [PATCH 11/13] Skip PyPy 3.8 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f75a044ce..25c76073c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ env: global: - CIBW_ARCHS=aarch64 - CIBW_CONFIG_SETTINGS="raqm=enable raqm=vendor fribidi=vendor" + - CIBW_SKIP=pp38-* language: python # Default Python version is usually 3.6 From 72ee8c5ef1de02cc91c6e851631c1781f4b3fb01 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 17 Nov 2023 18:39:37 +1100 Subject: [PATCH 12/13] Fixed bundling dylibs into arm64 wheels --- .github/workflows/wheels-dependencies.sh | 26 +++++++++--------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh index 410941c6e..3f7f48242 100755 --- a/.github/workflows/wheels-dependencies.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -61,18 +61,15 @@ function build_brotli { } function build { + if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then + export BUILD_PREFIX="/usr/local" + fi build_xz if [ -z "$IS_ALPINE" ] && [ -z "$IS_MACOS" ]; then yum remove -y zlib-devel fi build_new_zlib - if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then - ORIGINAL_BUILD_PREFIX=$BUILD_PREFIX - ORIGINAL_PKG_CONFIG_PATH=$PKG_CONFIG_PATH - BUILD_PREFIX=`dirname $(dirname $(which python))` - PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig" - fi build_simple xcb-proto 1.16.0 https://xorg.freedesktop.org/archive/individual/proto if [ -n "$IS_MACOS" ]; then if [[ "$CIBW_ARCHS" == "arm64" ]]; then @@ -87,18 +84,16 @@ function build { sed s/\${pc_sysrootdir\}// /usr/local/share/pkgconfig/xcb-proto.pc > /usr/local/lib/pkgconfig/xcb-proto.pc fi build_simple libxcb $LIBXCB_VERSION https://www.x.org/releases/individual/lib - if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then - BUILD_PREFIX=$ORIGINAL_BUILD_PREFIX - PKG_CONFIG_PATH=$ORIGINAL_PKG_CONFIG_PATH - fi build_libjpeg_turbo - if [[ -n "$IS_MACOS" ]]; then - rm /usr/local/lib/libjpeg.dylib - fi build_tiff build_libpng build_lcms2 + if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then + for dylib in libjpeg.dylib libtiff.dylib liblcms2.dylib; do + cp $BUILD_PREFIX/lib/$dylib /opt/arm64-builds/lib + done + fi build_openjpeg ORIGINAL_CFLAGS=$CFLAGS @@ -135,13 +130,12 @@ curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-de untar pillow-depends-main.zip if [[ -n "$IS_MACOS" ]]; then - # webp, zstd, xz, libtiff, libxcb cause a conflict with building webp, libtiff, libxcb + # webp, libtiff, libxcb cause a conflict with building webp, libtiff, libxcb # libxdmcp causes an issue on macOS < 11 - # curl from brew requires zstd, use system curl # if php is installed, brew tries to reinstall these after installing openblas # remove cairo to fix building harfbuzz on arm64 # remove lcms2 and libpng to fix building openjpeg on arm64 - brew remove --ignore-dependencies webp zstd xz libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript + brew remove --ignore-dependencies webp libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript brew install pkg-config fi From 07c216c0e1577385a521c02339d339e6e9596537 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 18 Nov 2023 06:43:40 +1100 Subject: [PATCH 13/13] Removed zstd again --- .github/workflows/wheels-dependencies.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh index 3f7f48242..4b9a4d46b 100755 --- a/.github/workflows/wheels-dependencies.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -135,7 +135,9 @@ if [[ -n "$IS_MACOS" ]]; then # if php is installed, brew tries to reinstall these after installing openblas # remove cairo to fix building harfbuzz on arm64 # remove lcms2 and libpng to fix building openjpeg on arm64 - brew remove --ignore-dependencies webp libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript + # remove zstd to avoid inclusion on x86_64 + # curl from brew requires zstd, use system curl + brew remove --ignore-dependencies webp libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript zstd brew install pkg-config fi