Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ impl BuildBackendMetadataSpec {
} else if let Some(build_source) = &discovered_backend.init_params.build_source {
Some(
command_dispatcher
.pin_and_checkout(build_source.clone())
.pin_and_checkout(
build_source.clone(),
Some(&discovered_backend.init_params.manifest_path),
)
.await
.map_err_with(BuildBackendMetadataError::SourceCheckout)?,
)
Expand Down
21 changes: 16 additions & 5 deletions crates/pixi_command_dispatcher/src/command_dispatcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,10 @@ impl CommandDispatcher {
///
/// This function resolves the source specification to a concrete checkout
/// by:
/// 1. For path sources: Resolving relative paths against the root directory
/// 1. For path sources: Resolving relative paths against the root directory or against an alternative root path
///
/// i.e. in the case of an out-of-tree build.
///
/// 2. For git sources: Cloning or fetching the repository and checking out
/// the specified reference
/// 3. For URL sources: Downloading and extracting the archive (currently
Expand All @@ -578,6 +581,7 @@ impl CommandDispatcher {
pub async fn pin_and_checkout(
&self,
source_location_spec: SourceLocationSpec,
alternative_root_path: Option<&Path>,
) -> Result<SourceCheckout, CommandDispatcherError<SourceCheckoutError>> {
match source_location_spec {
SourceLocationSpec::Url(url) => {
Expand All @@ -586,7 +590,7 @@ impl CommandDispatcher {
SourceLocationSpec::Path(path) => {
let source_path = self
.data
.resolve_typed_path(path.path.to_path())
.resolve_typed_path(path.path.to_path(), alternative_root_path)
.map_err(SourceCheckoutError::from)
.map_err(CommandDispatcherError::Failed)?;
Ok(SourceCheckout {
Expand Down Expand Up @@ -618,7 +622,7 @@ impl CommandDispatcher {
PinnedSourceSpec::Path(ref path) => {
let source_path = self
.data
.resolve_typed_path(path.path.to_path())
.resolve_typed_path(path.path.to_path(), None)
.map_err(SourceCheckoutError::from)
.map_err(CommandDispatcherError::Failed)?;
Ok(SourceCheckout {
Expand Down Expand Up @@ -653,7 +657,11 @@ impl CommandDispatcherData {
///
/// This function does not check if the path exists and also does not follow
/// symlinks.
fn resolve_typed_path(&self, path_spec: Utf8TypedPath) -> Result<PathBuf, InvalidPathError> {
fn resolve_typed_path(
&self,
path_spec: Utf8TypedPath,
alternative_root_path: Option<&Path>,
) -> Result<PathBuf, InvalidPathError> {
if path_spec.is_absolute() {
Ok(Path::new(path_spec.as_str()).to_path_buf())
} else if let Ok(user_path) = path_spec.strip_prefix("~/") {
Expand All @@ -663,7 +671,10 @@ impl CommandDispatcherData {
debug_assert!(home_dir.is_absolute());
normalize_absolute_path(&home_dir.join(Path::new(user_path.as_str())))
} else {
let root_dir = self.root_dir.as_path();
let root_dir = match alternative_root_path {
Some(root_path) => root_path,
None => self.root_dir.as_path(),
};
let native_path = Path::new(path_spec.as_str());
debug_assert!(root_dir.is_absolute());
normalize_absolute_path(&root_dir.join(native_path))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl SourceMetadataCollector {
// will pick build_source; we only override the build pin later.
let source = self
.command_queue
.pin_and_checkout(spec.location)
.pin_and_checkout(spec.location, None)
.await
.map_err(|err| CollectSourceMetadataError::SourceCheckoutError {
name: name.as_source().to_string(),
Expand Down
11 changes: 10 additions & 1 deletion crates/pixi_command_dispatcher/src/source_build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,16 @@ impl SourceBuildSpec {
discovered_backend.init_params.build_source.clone()
{
let build_source_checkout = command_dispatcher
.pin_and_checkout(manifest_build_source)
.pin_and_checkout(
manifest_build_source,
Some(
discovered_backend
.init_params
.manifest_path
.parent()
.expect("manifest path should have a parent directory"),
),
)
.await
.map_err_with(SourceBuildError::SourceCheckout)?;
build_source_checkout.path
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_global/src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ impl Project {
) -> Result<PackageName, InferPackageNameError> {
let command_dispatcher = self.command_dispatcher()?;
let checkout = command_dispatcher
.pin_and_checkout(source_spec.location)
.pin_and_checkout(source_spec.location, None)
.await
.map_err(|e| InferPackageNameError::BuildBackendMetadata(Box::new(e)))?;

Expand Down
Loading