From bbea38e2042b758c31bfa931ca8878eb08dded8e Mon Sep 17 00:00:00 2001 From: Owen Leung Date: Mon, 21 Oct 2024 21:37:48 +0800 Subject: [PATCH] Fix fmt & clippy CI job. Use upload & download artifact github action to test pip install without toolchain --- .github/workflows/test.yml | 42 +++++++++++++++++++++++++++++++++++--- src/build_context.rs | 11 +++++----- src/main.rs | 20 ++++++++++-------- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0853e657..dd3f261d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -531,7 +531,7 @@ jobs: - repository: "oxigraph/oxigraph" manifest-dir: "python" - test-pip-install-without-toolchain: + build-maturin-wheel: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -551,8 +551,44 @@ jobs: run: pip install --force-reinstall ./dist/*.whl - name: test run: maturin sdist --manifest-path ./test-crates/hello-world/Cargo.toml -o ./target/hello-world/sdist - - name: Remove toolchain - run: rustup self uninstall -y + - name: Upload sdist + id: upload-sdist + uses: actions/upload-artifact@v3 + env: + ACTIONS_RUNTIME_TOKEN: abc + with: + name: hello-world-sdist + path: ./target/hello-world/sdist/*.tar.gz + - name: Upload wheels + id: upload-wheel + uses: actions/upload-artifact@v3 + env: + ACTIONS_RUNTIME_TOKEN: abc + with: + name: maturin-wheel + path: ./dist/*.whl + + test-pip-install-without-toolchain: + runs-on: ubuntu-latest + needs: [build-maturin-wheel] + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Download sdist from previous job + uses: actions/download-artifact@v3 + with: + name: hello-world-sdist + path: ./target/hello-world/sdist + - name: Download wheel from previous job + uses: actions/download-artifact@v3 + with: + name: maturin-wheel + path: ./dist/*.whl + - name: Install maturin whl + run: pip install --force-reinstall ./dist/*.whl - name: pip install run: | export MATURIN_PEP517_ARGS="--verbose" diff --git a/src/build_context.rs b/src/build_context.rs index 75df7ce0..1fb10239 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -1180,10 +1180,12 @@ impl BuildContext { { Command::new("cmd") .args(&["/C", tf.path().to_str().unwrap()]) + .args("-y") + .arg("--default-toolchain") + .arg("none") .env("RUSTUP_HOME", rustup_home) .env("CARGO_HOME", cargo_home) - .status() - .context("Failed to execute rustup script on Windows")?; + .status()?; } Ok(()) @@ -1203,7 +1205,7 @@ impl BuildContext { Command::new("sh") .arg("-c") .arg(format!(". {}", cargo_env_path)) - .status()?; // Execute and get the status + .status()?; let rustup_command = format!("{}/bin/rustup", cargo_home); Command::new(rustup_command) @@ -1219,8 +1221,7 @@ impl BuildContext { env::set_var("PATH", &new_path); Command::new("cmd") .args(&["/C", "rustup default stable"]) - .status() - .context("Failed to set rustup default stable on Windows"); + .status(); } Ok(()) diff --git a/src/main.rs b/src/main.rs index fd71fadb..1a3f211e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -277,15 +277,17 @@ fn pep517(subcommand: Pep517Command) -> Result<()> { strip, } => { assert_eq!(build_options.interpreter.len(), 1); - #[cfg(feature = "rustls")] { - if !BuildContext::is_toolchain_installed() { - let home_dir = home_dir().context("Unable to get user home directory")?; - let home_dir_str = home_dir - .to_str() - .context("Unable to convert home directory string")?; - let _ = BuildContext::install_installer(home_dir_str, home_dir_str); - let _ = BuildContext::install_toolchain(home_dir_str) - .context("Unable to install rust toolchain")?; + #[cfg(feature = "rustls")] + { + if !BuildContext::is_toolchain_installed() { + let home_dir = home_dir().context("Unable to get user home directory")?; + let home_dir_str = home_dir + .to_str() + .context("Unable to convert home directory string")?; + BuildContext::install_installer(home_dir_str, home_dir_str) + .context("Unable to install installer")?; + BuildContext::install_toolchain(home_dir_str) + .context("Unable to install rust toolchain")?; } } let context = build_options.into_build_context(true, strip, false)?;