Skip to content

Commit

Permalink
write recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Aug 6, 2024
1 parent 720cd44 commit f199d27
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Cargo.lock

# Visual studio files
.vs/

# pixi environments
.pixi
*.egg-info

# Output directory
pixi-build-python-output/
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
3 changes: 2 additions & 1 deletion crates/pixi-build-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
22 changes: 20 additions & 2 deletions crates/pixi-build-python/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(())
}

0 comments on commit f199d27

Please sign in to comment.