diff --git a/.github/workflows/build-maturin-wheels.yaml b/.github/workflows/build-maturin-wheels.yaml index e10452c..de44412 100644 --- a/.github/workflows/build-maturin-wheels.yaml +++ b/.github/workflows/build-maturin-wheels.yaml @@ -133,10 +133,10 @@ jobs: maturin-version: ${{ needs.source.outputs.maturin-version }} target: ${{ matrix.target }} args: >- - -m ${{ inputs.package-path }}/Cargo.toml --locked --release --out dist --target-dir target --interpreter ${{ matrix.python || '3.15' }} ${{ matrix.args }} + -m ${{ inputs.package-path }}/Cargo.toml --locked --release --out dist --target-dir target ${{ matrix.python && format('--interpreter {0}', matrix.python) || '' }} ${{ matrix.args }} manylinux: ${{ matrix.manylinux || 'auto' }} docker-options: --env SOURCE_DATE_EPOCH - sccache: ${{ needs.source.outputs.release != 'true' }} + sccache: ${{ needs.source.outputs.release != 'true' && !startsWith(matrix.os, 'windows') }} - name: 🏗️ Run post-build command if: ${{ inputs.post-build-command != '' }} shell: bash diff --git a/README.md b/README.md index 28b51c3..1b486cf 100644 --- a/README.md +++ b/README.md @@ -545,13 +545,15 @@ Each matrix entry takes these keys: - `os`: runner label, used as `runs-on`. - `target`: Rust target triple passed to maturin. - `artifact`: suffix of the uploaded `-wheels-` artifact. -- `python`: space-separated interpreters for `--interpreter`; default `3.15`. +- `python`: space-separated interpreters for `--interpreter`. Leave it out for cross targets, where maturin finds no + host interpreter; a native entry without it builds for the job's Python 3.15. - `manylinux`: manylinux or musllinux policy; default `auto`. - `args`: extra maturin arguments, such as `--zig`. `package-path` is the directory holding the package's `Cargo.toml`; the sdist is built from it. `release-build` defaults -to `false`, but any tag ref runs in release mode too, so a tag caller can omit it. Release mode builds without sccache. -`workflow_call` defaults cannot be expressions, so the workflow combines the two inside. +to `false`, but any tag ref runs in release mode too, so a tag caller can omit it. Release mode and Windows entries +build without sccache, which breaks MSVC builds of C dependencies. `workflow_call` defaults cannot be expressions, so +the workflow combines the two inside. `pre-build-command` runs once in the source job from the checkout root, so every wheel job builds the same tree. Use it for a version bump, which must happen before the source artifact is written. `post-build-command` runs in each wheel job diff --git a/changelog.d/+maturin-cross-targets.bugfix.md b/changelog.d/+maturin-cross-targets.bugfix.md new file mode 100644 index 0000000..5421d78 --- /dev/null +++ b/changelog.d/+maturin-cross-targets.bugfix.md @@ -0,0 +1,2 @@ +`build-maturin-wheels` passes `--interpreter` only for matrix entries that set `python`, so cross targets build again, +and it no longer enables sccache on Windows, where it broke MSVC builds of C dependencies. diff --git a/tests/build_maturin_wheels/test_workflow.py b/tests/build_maturin_wheels/test_workflow.py index 8754824..ceca873 100644 --- a/tests/build_maturin_wheels/test_workflow.py +++ b/tests/build_maturin_wheels/test_workflow.py @@ -42,15 +42,22 @@ def test_artifact_names_match_the_callers_names(workflow: JsonObject) -> None: } -def test_release_mode_disables_sccache_for_tags_or_input(workflow: JsonObject) -> None: +def test_sccache_is_off_for_releases_and_windows(workflow: JsonObject) -> None: assert at(workflow, "jobs", "source", "outputs", "release") == ( "${{ inputs.release-build || startsWith(github.ref, 'refs/tags/') }}" ) assert at(step(workflow, "build", "🏗️ Build wheels"), "with", "sccache") == ( - "${{ needs.source.outputs.release != 'true' }}" + "${{ needs.source.outputs.release != 'true' && !startsWith(matrix.os, 'windows') }}" ) +def test_interpreter_is_passed_only_for_entries_that_name_one(workflow: JsonObject) -> None: + args = text(at(step(workflow, "build", "🏗️ Build wheels"), "with", "args")) + + assert "${{ matrix.python && format('--interpreter {0}', matrix.python) || '' }}" in args + assert "'3.15'" not in args + + def test_post_build_command_runs_after_maturin_and_before_upload(workflow: JsonObject) -> None: names = [item["name"] for item in steps(workflow, "build")]