Skip to content

Commit 7003ffa

Browse files
wolfvHofer-Julian
andauthored
feat: glob recipe.yaml parent directory more properly (#137)
* handle editable python installs better with globs * fix editable * use the right parent directory for recipe.yaml to get proper hashes * add in all path sources from the recipe * Use different glob if source is a file --------- Co-authored-by: Julian Hofer <julianhofer@gnome.org>
1 parent 804e16d commit 7003ffa

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

crates/pixi-build-rattler-build/src/protocol.rs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use fs_err::tokio as tokio_fs;
55
use miette::{Context, IntoDiagnostic};
66
use pixi_build_backend::{
77
protocol::{Protocol, ProtocolInstantiator},
8+
source::Source,
89
tools::RattlerBuild,
910
utils::TemporaryRenderedRecipe,
1011
};
@@ -135,8 +136,6 @@ impl Protocol for RattlerBuildBackend {
135136

136137
let mut solved_packages = vec![];
137138

138-
eprintln!("before outputs ");
139-
140139
for output in outputs {
141140
let temp_recipe = TemporaryRenderedRecipe::from_output(&output)?;
142141
let tool_config = &tool_config;
@@ -194,7 +193,7 @@ impl Protocol for RattlerBuildBackend {
194193

195194
Ok(CondaMetadataResult {
196195
packages: solved_packages,
197-
input_globs: None,
196+
input_globs: Some(input_globs(&self.recipe_source, None)),
198197
})
199198
}
200199

@@ -318,7 +317,7 @@ impl Protocol for RattlerBuildBackend {
318317

319318
built.push(CondaBuiltPackage {
320319
output_file: build_path,
321-
input_globs: Vec::from([self.recipe_source.name.clone()]),
320+
input_globs: input_globs(&self.recipe_source, output.finalized_sources.as_ref()),
322321
name: output.name().as_normalized().to_string(),
323322
version: output.version().to_string(),
324323
build: build_string.to_string(),
@@ -329,6 +328,42 @@ impl Protocol for RattlerBuildBackend {
329328
}
330329
}
331330

331+
fn input_globs(
332+
source: &Source,
333+
package_sources: Option<&Vec<rattler_build::recipe::parser::Source>>,
334+
) -> Vec<String> {
335+
let mut input_globs = vec![];
336+
let parent = if source.path.is_file() {
337+
// use the parent path as glob
338+
if let Some(parent) = source.path.parent() {
339+
parent.to_path_buf()
340+
} else {
341+
source.path.clone()
342+
}
343+
} else {
344+
// use the source path as glob
345+
source.path.clone()
346+
};
347+
348+
// add the source path as glob
349+
input_globs.push(format!("{}/**", parent.display()));
350+
351+
if let Some(package_sources) = package_sources {
352+
for source in package_sources {
353+
if let rattler_build::recipe::parser::Source::Path(path_source) = source {
354+
// add the package source path as glob
355+
if path_source.path.is_dir() {
356+
input_globs.push(format!("{}/**", path_source.path.display()));
357+
} else {
358+
input_globs.push(path_source.path.display().to_string());
359+
}
360+
}
361+
}
362+
}
363+
364+
input_globs
365+
}
366+
332367
#[async_trait::async_trait]
333368
impl ProtocolInstantiator for RattlerBuildBackendInstantiator {
334369
async fn initialize(

0 commit comments

Comments
 (0)