Skip to content

Commit

Permalink
fix CI "build wheels" step for rustup no longer installing default to…
Browse files Browse the repository at this point in the history
…olchain (Cherry-pick of #22037) (#22039)

Fix the "Build wheels" step for a breaking change in [Rustup
v1.28.0](https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html) which
no longer installs a default toolchain any more.

Use `rustup default` to install the applicable toolchain because it is
idempotent and will install the toolchain if it is not already
installed. `rustup toolchain install` by design will try to install even
if the toolchain is already installed. See
rust-lang/rustup#710 for discussion of this
distinction.

Closes #22036

---------

Co-authored-by: Tom Dyas <[email protected]>
  • Loading branch information
WorkerPants and tdyas authored Mar 4, 2025
1 parent 60f59d9 commit 55469fb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ jobs:
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
'
- name: Install Rust toolchain
run: '# Set the default toolchain. Installs the toolchain if it is not already
installed.
rustup default 1.82.0
cargo version
'
- name: Expose Pythons
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -116,6 +125,15 @@ jobs:
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
'
- name: Install Rust toolchain
run: '# Set the default toolchain. Installs the toolchain if it is not already
installed.
rustup default 1.82.0
cargo version
'
- name: Expose Pythons
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ jobs:
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
'
- name: Install Rust toolchain
run: '# Set the default toolchain. Installs the toolchain if it is not already installed.
rustup default 1.82.0
cargo version
'
- name: Expose Pythons
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -418,6 +426,14 @@ jobs:
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
'
- name: Install Rust toolchain
run: '# Set the default toolchain. Installs the toolchain if it is not already installed.
rustup default 1.82.0
cargo version
'
- name: Expose Pythons
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
Expand Down
28 changes: 20 additions & 8 deletions src/python/pants_release/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,28 @@ def rust_channel() -> str:
return cast(str, rust_toolchain["toolchain"]["channel"])


def install_rustup() -> Step:
return {
"name": "Install rustup",
"run": dedent(
"""\
def install_rustup() -> list[Step]:
return [
{
"name": "Install rustup",
"run": dedent(
"""\
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v -y --default-toolchain none
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
"""
),
}
),
},
{
"name": "Install Rust toolchain",
"run": dedent(
f"""\
# Set the default toolchain. Installs the toolchain if it is not already installed.
rustup default {rust_channel()}
cargo version
"""
),
},
]


def install_pythons(versions: list[str]) -> Step:
Expand Down Expand Up @@ -832,7 +844,7 @@ def build_wheels_job(
if container:
initial_steps = [
*checkout(containerized=True, ref=for_deploy_ref),
install_rustup(),
*install_rustup(),
{
"name": "Expose Pythons",
"run": dedent(
Expand Down

0 comments on commit 55469fb

Please sign in to comment.