Skip to content

Commit

Permalink
fix: ignore missing about section and missing build.sh / build.bat (#196
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wolfv authored Oct 6, 2023
1 parent 8d9be30 commit 105ea04
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
24 changes: 18 additions & 6 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,22 @@ pub fn get_conda_build_script(
let recipe_file = directories.recipe_dir.join(script);
tracing::info!("Reading recipe file: {:?}", recipe_file);

let mut orig_build_file = File::open(recipe_file)?;
let mut orig_build_file_text = String::new();
orig_build_file.read_to_string(&mut orig_build_file_text)?;
orig_build_file_text
if !recipe_file.exists() {
if recipe.build.script.is_none() {
tracing::info!("Empty build script");
String::new()
} else {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
format!("Recipe file {:?} does not exist", recipe_file),
));
}
} else {
let mut orig_build_file = File::open(recipe_file)?;
let mut orig_build_file_text = String::new();
orig_build_file.read_to_string(&mut orig_build_file_text)?;
orig_build_file_text
}
} else {
script
};
Expand Down Expand Up @@ -154,9 +166,9 @@ pub async fn run_build(
let mut channels = vec![directories.output_dir.to_string_lossy().to_string()];
channels.extend(output.build_configuration.channels.clone());

if let Some(source) = &output.recipe.source {
if !output.recipe.source.is_empty() {
fetch_sources(
source,
&output.recipe.source,
&directories.work_dir,
&directories.recipe_dir,
&directories.output_dir,
Expand Down
10 changes: 7 additions & 3 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub struct BuildOptions {
}

#[serde_as]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct About {
#[serde_as(as = "Option<OneOrMany<_, PreferOne>>")]
pub home: Option<Vec<Url>>,
Expand Down Expand Up @@ -228,6 +228,7 @@ pub struct Recipe {
pub build: BuildOptions,
#[serde(default)]
pub requirements: Requirements,
#[serde(default)]
pub about: About,
}

Expand Down Expand Up @@ -470,14 +471,17 @@ pub struct RenderedRecipe {
/// Information about the package
pub package: Package,
/// The source section of the recipe
#[serde_as(deserialize_as = "Option<OneOrMany<_, PreferOne>>")]
pub source: Option<Vec<Source>>,
#[serde_as(deserialize_as = "OneOrMany<_, PreferOne>")]
#[serde(default)]
pub source: Vec<Source>,
/// The build section of the recipe
#[serde(default)]
pub build: BuildOptions,
/// The requirements section of the recipe
#[serde(default)]
pub requirements: Requirements,
/// The about section of the recipe
#[serde(default)]
pub about: About,
/// The test section of the recipe
pub test: Option<Test>,
Expand Down

0 comments on commit 105ea04

Please sign in to comment.