From 2e8c44643c23f9bb087c6989fdab79ad1bdf7cc1 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 3 Jul 2025 00:53:31 -0400 Subject: [PATCH] Move cibuildwheel configuration to pyproject.toml This allows developers to test out the build locally. With this, I was able to fix the test command by setting `PIP_PREFER_BINARY` to avoid re-building Pillow, which accidentally dropped manylinux2014 wheels in the latest release: https://github.com/python-pillow/Pillow/issues/9057 Note also that we previously set `CIBW_AFTER_BUILD`, but this doesn't seem to be a valid setting. Thus I have dropped the `twine check`, which only tests the `README` rendering and so checking the sdist is sufficient. Additionally, I have commented out the license check, as we cannot do multiple licenses with meson-python without PEP639 (#28982). --- .github/labeler.yml | 4 ++- .github/workflows/cibuildwheel.yml | 30 ---------------------- pyproject.toml | 41 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 75adfed57f43..b31be7f4a057 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,7 +1,9 @@ --- "CI: Run cibuildwheel": - changed-files: - - any-glob-to-any-file: ['.github/workflows/cibuildwheel.yml'] + - any-glob-to-any-file: + - '.github/workflows/cibuildwheel.yml' + - 'pyproject.toml' "CI: Run cygwin": - changed-files: - any-glob-to-any-file: ['.github/workflows/cygwin.yml'] diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index fececb0dfc40..abee3907b70a 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -94,31 +94,6 @@ jobs: needs: build_sdist name: Build wheels on ${{ matrix.os }} for ${{ matrix.cibw_archs }} runs-on: ${{ matrix.os }} - env: - CIBW_BEFORE_BUILD: >- - rm -rf {package}/build - CIBW_BEFORE_BUILD_WINDOWS: >- - pip install delvewheel && - rm -rf {package}/build - CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >- - delvewheel repair -w {dest_dir} {wheel} - CIBW_AFTER_BUILD: >- - twine check {wheel} && - python {package}/ci/check_wheel_licenses.py {wheel} - # On Windows, we explicitly request MSVC compilers (as GitHub Action runners have - # MinGW on PATH that would be picked otherwise), switch to a static build for - # runtimes, but use dynamic linking for `VCRUNTIME140.dll`, `VCRUNTIME140_1.dll`, - # and the UCRT. This avoids requiring specific versions of `MSVCP140.dll`, while - # keeping shared state with the rest of the Python process/extensions. - CIBW_CONFIG_SETTINGS_WINDOWS: >- - setup-args="--vsenv" - setup-args="-Db_vscrt=mt" - setup-args="-Dcpp_link_args=['ucrt.lib','vcruntime.lib','/nodefaultlib:libucrt.lib','/nodefaultlib:libvcruntime.lib']" - CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 - CIBW_SKIP: "*-musllinux_aarch64" - CIBW_TEST_COMMAND: >- - python {package}/ci/check_version_number.py - MACOSX_DEPLOYMENT_TARGET: "10.12" strategy: matrix: include: @@ -148,11 +123,6 @@ jobs: CIBW_BUILD: "cp314-* cp314t-*" CIBW_ENABLE: "cpython-freethreading cpython-prerelease" CIBW_ARCHS: ${{ matrix.cibw_archs }} - CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_BEFORE_TEST: >- - python -m pip install - --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple - --upgrade --pre --only-binary=:all: contourpy numpy pillow - name: Build wheels for CPython 3.13 uses: pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0 diff --git a/pyproject.toml b/pyproject.toml index b980e512769a..8f9654ad8b96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,47 @@ local_scheme = "node-and-date" parentdir_prefix_version = "matplotlib-" fallback_version = "0.0+UNKNOWN" +[tool.cibuildwheel] +skip = "*-musllinux_aarch64" +manylinux-x86_64-image = "manylinux2014" + +before-build = "rm -rf {package}/build" +test-command = [ + # "python {package}/ci/check_wheel_licenses.py {wheel}", + "python {package}/ci/check_version_number.py", +] +test-environment = "PIP_PREFER_BINARY=true" + +[tool.cibuildwheel.macos.environment] +MACOSX_DEPLOYMENT_TARGET = "10.12" + +[tool.cibuildwheel.windows] +before-build = [ + "pip install delvewheel", + "rm -rf {package}/build", +] +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" + +[tool.cibuildwheel.windows.config-settings] +# On Windows, we explicitly request MSVC compilers (as GitHub Action runners have +# MinGW on PATH that would be picked otherwise), switch to a static build for +# runtimes, but use dynamic linking for `VCRUNTIME140.dll`, `VCRUNTIME140_1.dll`, +# and the UCRT. This avoids requiring specific versions of `MSVCP140.dll`, while +# keeping shared state with the rest of the Python process/extensions. +setup-args = [ + "--vsenv", + "-Db_vscrt=mt", + "-Dcpp_link_args=['ucrt.lib','vcruntime.lib','/nodefaultlib:libucrt.lib','/nodefaultlib:libvcruntime.lib']", +] + +[[tool.cibuildwheel.overrides]] +select = "cp314*" +manylinux-x86_64-image = "manylinux_2_28" +before-test = """ + python -m pip install \ + --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ + --upgrade --pre --only-binary=:all: contourpy numpy pillow""" + [tool.isort] known_pydata = "numpy, matplotlib.pyplot" known_firstparty = "matplotlib,mpl_toolkits"