Skip to content

Commit 3adcfa3

Browse files
authored
fix: change to use manifest_root other backends (#456)
1 parent d56f6e1 commit 3adcfa3

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

crates/pixi-build-cmake/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,28 @@ impl GenerateRecipe for CMakeGenerator {
3131
&self,
3232
model: &ProjectModelV1,
3333
config: &Self::Config,
34-
manifest_root: PathBuf,
34+
manifest_path: PathBuf,
3535
host_platform: Platform,
3636
_python_params: Option<PythonParams>,
3737
variants: &HashSet<NormalizedKey>,
3838
_channels: Vec<ChannelUrl>,
3939
) -> miette::Result<GeneratedRecipe> {
40+
// Determine the manifest root, because `manifest_path` can be
41+
// either a direct file path or a directory path.
42+
let manifest_root = if manifest_path.is_file() {
43+
manifest_path
44+
.parent()
45+
.ok_or_else(|| {
46+
miette::Error::msg(format!(
47+
"Manifest path {} is a file but has no parent directory.",
48+
manifest_path.display()
49+
))
50+
})?
51+
.to_path_buf()
52+
} else {
53+
manifest_path.clone()
54+
};
55+
4056
let mut generated_recipe =
4157
GeneratedRecipe::from_model(model.clone(), &mut DefaultMetadataProvider)
4258
.into_diagnostic()?;

crates/pixi-build-mojo/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,28 @@ impl GenerateRecipe for MojoGenerator {
2828
&self,
2929
model: &ProjectModelV1,
3030
config: &Self::Config,
31-
manifest_root: PathBuf,
31+
manifest_path: PathBuf,
3232
host_platform: Platform,
3333
_python_params: Option<PythonParams>,
3434
variants: &HashSet<NormalizedKey>,
3535
_channels: Vec<ChannelUrl>,
3636
) -> miette::Result<GeneratedRecipe> {
37+
// Determine the manifest root, because `manifest_path` can be
38+
// either a direct file path or a directory path.
39+
let manifest_root = if manifest_path.is_file() {
40+
manifest_path
41+
.parent()
42+
.ok_or_else(|| {
43+
miette::Error::msg(format!(
44+
"Manifest path {} is a file but has no parent directory.",
45+
manifest_path.display()
46+
))
47+
})?
48+
.to_path_buf()
49+
} else {
50+
manifest_path.clone()
51+
};
52+
3753
let mut generated_recipe =
3854
GeneratedRecipe::from_model(model.clone(), &mut DefaultMetadataProvider)
3955
.into_diagnostic()?;

crates/pixi-build-python/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,30 @@ impl GenerateRecipe for PythonGenerator {
5656
&self,
5757
model: &ProjectModelV1,
5858
config: &Self::Config,
59-
manifest_root: PathBuf,
59+
manifest_path: PathBuf,
6060
host_platform: Platform,
6161
python_params: Option<PythonParams>,
6262
variants: &HashSet<NormalizedKey>,
6363
_channels: Vec<ChannelUrl>,
6464
) -> miette::Result<GeneratedRecipe> {
6565
let params = python_params.unwrap_or_default();
6666

67+
// Determine the manifest root, because `manifest_path` can be
68+
// either a direct file path or a directory path.
69+
let manifest_root = if manifest_path.is_file() {
70+
manifest_path
71+
.parent()
72+
.ok_or_else(|| {
73+
miette::Error::msg(format!(
74+
"Manifest path {} is a file but has no parent directory.",
75+
manifest_path.display()
76+
))
77+
})?
78+
.to_path_buf()
79+
} else {
80+
manifest_path.clone()
81+
};
82+
6783
let mut pyproject_metadata_provider = PyprojectMetadataProvider::new(
6884
&manifest_root,
6985
config

crates/pixi-build-rust/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,30 @@ impl GenerateRecipe for RustGenerator {
3636
&self,
3737
model: &ProjectModelV1,
3838
config: &Self::Config,
39-
manifest_root: PathBuf,
39+
manifest_path: PathBuf,
4040
host_platform: Platform,
4141
_python_params: Option<PythonParams>,
4242
variants: &HashSet<NormalizedKey>,
4343
_channels: Vec<ChannelUrl>,
4444
) -> miette::Result<GeneratedRecipe> {
4545
// Construct a CargoMetadataProvider to read the Cargo.toml file
4646
// and extract metadata from it.
47+
// Determine the manifest root, because `manifest_path` can be
48+
// either a direct file path or a directory path.
49+
let manifest_root = if manifest_path.is_file() {
50+
manifest_path
51+
.parent()
52+
.ok_or_else(|| {
53+
miette::Error::msg(format!(
54+
"Manifest path {} is a file but has no parent directory.",
55+
manifest_path.display()
56+
))
57+
})?
58+
.to_path_buf()
59+
} else {
60+
manifest_path.clone()
61+
};
62+
4763
let mut cargo_metadata = CargoMetadataProvider::new(
4864
&manifest_root,
4965
config.ignore_cargo_manifest.is_some_and(|ignore| ignore),

0 commit comments

Comments
 (0)