Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build-maturin-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<package-name>-wheels-<artifact>` 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
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/+maturin-cross-targets.bugfix.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 9 additions & 2 deletions tests/build_maturin_wheels/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

Expand Down