Skip to content

Commit

Permalink
Fix fmt & clippy CI job. Use upload & download artifact github action…
Browse files Browse the repository at this point in the history
… to test pip install without toolchain
  • Loading branch information
Owen-CH-Leung committed Oct 21, 2024
1 parent 3c78b7c commit bbea38e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand All @@ -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)
Expand All @@ -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(())
Expand Down
20 changes: 11 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit bbea38e

Please sign in to comment.