diff --git a/.gitignore b/.gitignore index 1286bae..539454d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,10 @@ Cargo.lock # Visual studio files .vs/ + # pixi environments .pixi *.egg-info + +# Output directory +pixi-build-python-output/ diff --git a/Cargo.toml b/Cargo.toml index 371e112..28a8459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" [workspace.dependencies] clap = "4.5.11" -pixi_manifest = { git = "https://github.com/prefix-dev/pixi", branch="main" } -pixi_consts = { git = "https://github.com/prefix-dev/pixi", branch="main" } +pixi_manifest = { git = "https://github.com/prefix-dev/pixi", branch = "main" } +pixi_consts = { git = "https://github.com/prefix-dev/pixi", branch = "main" } rattler-build = { git = "https://github.com/prefix-dev/rattler-build", branch = "main", default-features = false } rattler_conda_types = "0.26.3" rattler_package_streaming = "0.21.7" @@ -20,3 +20,4 @@ tokio = "1.37.0" tempfile = "3.10.1" clap-verbosity-flag = "2.2.1" tracing-subscriber = "0.3.18" +serde_yaml = "0.9.33" diff --git a/crates/pixi-build-python/Cargo.toml b/crates/pixi-build-python/Cargo.toml index 42c8cf7..f0dda29 100644 --- a/crates/pixi-build-python/Cargo.toml +++ b/crates/pixi-build-python/Cargo.toml @@ -16,5 +16,6 @@ reqwest-middleware = { workspace = true } reqwest = { workspace = true } tokio = { workspace = true, features = ["macros"] } tempfile = { workspace = true } -clap-verbosity-flag = { workspace = true} +clap-verbosity-flag = { workspace = true } tracing-subscriber = { workspace = true } +serde_yaml = { workspace = true } diff --git a/crates/pixi-build-python/src/main.rs b/crates/pixi-build-python/src/main.rs index f46ac94..eb9c2f0 100644 --- a/crates/pixi-build-python/src/main.rs +++ b/crates/pixi-build-python/src/main.rs @@ -1,6 +1,6 @@ mod consts; -use std::{collections::BTreeMap, path::PathBuf, str::FromStr, sync::Arc}; +use std::{collections::BTreeMap, io::BufWriter, path::PathBuf, str::FromStr, sync::Arc}; use chrono::Utc; use clap::Parser; @@ -174,7 +174,7 @@ async fn actual_main() -> miette::Result<()> { recipe: Recipe { schema_version: 1, package: Package { - version: version.to_string().parse().into_diagnostic()?, + version: version.into(), name, }, cache: None, @@ -262,8 +262,26 @@ async fn actual_main() -> miette::Result<()> { compression_threads: None, }; + let (recipe_file, recipe_path) = tempfile::Builder::new() + .prefix(".rendered-recipe") + .suffix(".yaml") + .tempfile_in(output_dir) + .into_diagnostic() + .context("failed to create temporary file for recipe")? + .into_parts(); + + // Write the recipe back to a file + serde_yaml::to_writer(BufWriter::new(recipe_file), &output.recipe) + .into_diagnostic() + .context("failed to write recipe to temporary file")?; + let (_output, package) = run_build(output, &tool_config).await?; eprintln!("Successfully build '{}'", package.display()); + // Remove the temporary recipe file. + std::fs::remove_file(recipe_path) + .into_diagnostic() + .context("failed to remove temporary recipe file")?; + Ok(()) }