Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion backends/pixi-build-ros/src/pixi_build_ros/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class ROSBackendConfig(pydantic.BaseModel, extra="forbid", arbitrary_types_allow
# Environment variables to set during the build
env: dict[str, str] | None = None
# Directory for debug files of this script
debug_dir: Path | None = pydantic.Field(default=None, alias="debug-dir")
debug_dir: Path | None = pydantic.Field(
default=None, validation_alias=pydantic.AliasChoices("debug-dir", "debug_dir")
)
# Extra input globs to include in the build hash
extra_input_globs: list[str] | None = pydantic.Field(default=None, alias="extra-input-globs")

Expand Down
11 changes: 9 additions & 2 deletions backends/pixi-build-ros/src/pixi_build_ros/metadata_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PackageXmlMetadataProvider(MetadataProvider): # type: ignore[misc] # Met
def __init__( # type: ignore[no-untyped-def] # no typing for args and kwargs
self,
package_xml_path: str,
manifest_root: str,
*args,
extra_input_globs: list[str] | None = None,
package_mapping_files: list[str] | None = None,
Expand All @@ -57,11 +58,13 @@ def __init__( # type: ignore[no-untyped-def] # no typing for args and kwargs

Args:
package_xml_path: Path to the package.xml file
manifest_root: Path to the manifest root directory
extra_input_globs: Additional glob patterns to include
package_mapping_files: Package mapping file paths to track as inputs
"""
super().__init__(*args, **kwargs)
self.package_xml_path = package_xml_path
self.manifest_root = manifest_root
self._package_data: PackageData | None = None
self._extra_input_globs = list(extra_input_globs or [])
self._package_mapping_files = list(package_mapping_files or [])
Expand Down Expand Up @@ -148,8 +151,9 @@ def license(self) -> str | None:
return None

def license_file(self) -> str | None:
"""Return package.xml as the license files."""
return "package.xml"
"""Return package.xml as the license files, relative to manifest_root."""
# TODO: This does not work currently, so return None
return None

def summary(self) -> str | None:
"""Return the description as summary from package.xml."""
Expand Down Expand Up @@ -189,6 +193,7 @@ class ROSPackageXmlMetadataProvider(PackageXmlMetadataProvider):
def __init__(
self,
package_xml_path: str,
manifest_root: str,
distro_name: str | None = None,
*,
extra_input_globs: list[str] | None = None,
Expand All @@ -199,12 +204,14 @@ def __init__(

Args:
package_xml_path: Path to the package.xml file
manifest_root: Path to the manifest root directory
distro_name: ROS distro. If None, will use the base package name without distro prefix.
extra_input_globs: Additional glob patterns to include
package_mapping_files: Package mapping file paths to track as inputs
"""
super().__init__(
package_xml_path,
manifest_root=manifest_root,
extra_input_globs=extra_input_globs,
package_mapping_files=package_mapping_files,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def generate_recipe(
package_mapping_files = [str(path) for path in backend_config.get_package_mapping_file_paths()]
metadata_provider = ROSPackageXmlMetadataProvider(
str(package_xml_path),
str(manifest_root),
backend_config.distro.name,
extra_input_globs=list(backend_config.extra_input_globs or []),
package_mapping_files=package_mapping_files,
Expand Down
3 changes: 1 addition & 2 deletions backends/pixi-build-ros/templates/build_catkin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ if [ "${PKG_NAME}" == "ros-noetic-catkin" ]; then
CATKIN_BUILD_BINARY_PACKAGE="OFF"
fi

rm -rf build
mkdir build
mkdir -p build
cd build

# necessary for correctly linking SIP files (from python_qt_bindings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
about:
homepage: https://test.io/custom_ros
license: LicenseRef-Apache License 2.0
license_file: package.xml
license_file: null
summary: Demo
description: Demo
documentation: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
about:
homepage: null
license: LicenseRef-Apache License 2.0
license_file: package.xml
license_file: null
summary: Demo
description: Demo
documentation: null
Expand Down Expand Up @@ -145,7 +145,7 @@
about:
homepage: null
license: LicenseRef-Apache License 2.0
license_file: package.xml
license_file: null
summary: Demo
description: Demo
documentation: null
Expand Down Expand Up @@ -222,7 +222,7 @@
about:
homepage: null
license: LicenseRef-Apache License 2.0
license_file: package.xml
license_file: null
summary: Demo
description: Demo
documentation: null
Expand Down
9 changes: 6 additions & 3 deletions backends/pixi-build-ros/tests/test_meta_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,35 @@
def test_metadata_provider(package_xmls: Path):
"""Test the MetaDataProvider class."""
package_xml_path = package_xmls / "custom_ros.xml"
metadata_provider = PackageXmlMetadataProvider(str(package_xml_path))
metadata_provider = PackageXmlMetadataProvider(str(package_xml_path), str(package_xmls))
assert metadata_provider.name() == "custom_ros"
assert metadata_provider.version() == "0.0.1"
assert metadata_provider.license() == "LicenseRef-Apache License 2.0"
assert metadata_provider.description() == "Demo"
assert metadata_provider.homepage() == "https://test.io/custom_ros"
assert metadata_provider.repository() == "https://github.com/test/custom_ros"
assert metadata_provider.license_file() is None


def test_ros_metadata_provider(package_xmls: Path):
"""Test the RosMetaDataProvider class."""
package_xml_path = package_xmls / "custom_ros.xml"
metadata_provider = ROSPackageXmlMetadataProvider(str(package_xml_path), distro_name="noetic")
metadata_provider = ROSPackageXmlMetadataProvider(str(package_xml_path), str(package_xmls), distro_name="noetic")
assert metadata_provider.name() == "ros-noetic-custom-ros"
assert metadata_provider.version() == "0.0.1"
assert metadata_provider.license() == "LicenseRef-Apache License 2.0"
assert metadata_provider.description() == "Demo"
assert metadata_provider.homepage() == "https://test.io/custom_ros"
assert metadata_provider.repository() == "https://github.com/test/custom_ros"
assert metadata_provider.license_file() is None


def test_metadata_provider_raises_on_broken_xml(package_xmls: Path):
"""Test that metadata provider raises an error when parsing broken XML."""
broken_xml_path = package_xmls / "broken.xml"

with pytest.raises(RuntimeError) as exc_info:
ROSPackageXmlMetadataProvider(str(broken_xml_path), distro_name="noetic")
ROSPackageXmlMetadataProvider(str(broken_xml_path), str(package_xmls), distro_name="noetic")

# Verify the exception contains location information
error = exc_info.value
Expand Down Expand Up @@ -85,6 +87,7 @@ def test_metadata_provider_includes_package_mapping_files_in_input_globs():
# Create metadata provider
metadata_provider = ROSPackageXmlMetadataProvider(
str(package_xml_path),
str(temp_path),
distro_name="noetic",
package_mapping_files=package_mapping_files,
)
Expand Down
8 changes: 6 additions & 2 deletions crates/pixi-build-backend/src/intermediate_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,13 @@ impl<T: GenerateRecipe> IntermediateBackend<T> {
(source_dir, manifest_rel_path)
}
Some(source_dir) => {
let manifest_rel_path = pathdiff::diff_paths(manifest_path, &source_dir)
let manifest_rel_path = pathdiff::diff_paths(&manifest_path, &source_dir)
.ok_or_else(|| {
miette::miette!("the manifest is not relative to the source directory")
miette::miette!(
"the manifest: {} is not relative to the source directory: {}",
manifest_path.display(),
source_dir.display()
)
})?;
(source_dir, manifest_rel_path)
}
Expand Down
1 change: 1 addition & 0 deletions crates/pixi-build-backend/tests/integration/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use crate::common::model::{convert_test_model_to_project_model_v1, load_project_model_from_json};
use imp::TestGenerateRecipe;

Check failure on line 4 in crates/pixi-build-backend/tests/integration/protocol.rs

View workflow job for this annotation

GitHub Actions / Check intra-doc links

unresolved import `imp`
use pixi_build_backend::{intermediate_backend::IntermediateBackend, protocol::Protocol};

Check failure on line 5 in crates/pixi-build-backend/tests/integration/protocol.rs

View workflow job for this annotation

GitHub Actions / Check intra-doc links

failed to resolve: use of unresolved module or unlinked crate `pixi_build_backend`
use pixi_build_types::procedures::conda_build_v1::{CondaBuildV1Output, CondaBuildV1Params};
use rattler_build::console_utils::LoggingOutputHandler;
use rattler_conda_types::{ChannelUrl, Platform};
Expand All @@ -26,6 +26,7 @@
#[serde(rename_all = "kebab-case")]
pub struct TestBackendConfig {
/// If set, internal state will be logged as files in that directory
#[serde(alias = "debug_dir")]
pub debug_dir: Option<PathBuf>,
}

Expand Down
1 change: 1 addition & 0 deletions crates/pixi-build-cmake/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct CMakeBackendConfig {
#[serde(default)]
pub env: IndexMap<String, String>,
/// If set, internal state will be logged as files in that directory
#[serde(alias = "debug_dir")]
pub debug_dir: Option<PathBuf>,
/// Extra input globs to include in addition to the default ones
#[serde(default)]
Expand Down
1 change: 1 addition & 0 deletions crates/pixi-build-mojo/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
pub env: IndexMap<String, String>,

/// Dir that can be specified for outputting pixi debug state.
#[serde(alias = "debug_dir")]
pub debug_dir: Option<PathBuf>,

/// Extra input globs to include in addition to the default ones.
Expand Down Expand Up @@ -435,7 +436,7 @@
}
}

/// Clean the package name for use in [`MojoPkgConfig`] and [`MojoBinconfig`].

Check failure on line 439 in crates/pixi-build-mojo/src/config.rs

View workflow job for this annotation

GitHub Actions / Check intra-doc links

unresolved link to `MojoBinconfig`
///
/// This just entails converting - to _.
pub fn clean_project_name(s: &str) -> String {
Expand Down
1 change: 1 addition & 0 deletions crates/pixi-build-python/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct PythonBackendConfig {
#[serde(default)]
pub env: IndexMap<String, String>,
/// If set, internal state will be logged as files in that directory
#[serde(alias = "debug_dir")]
pub debug_dir: Option<PathBuf>,
/// Extra input globs to include in addition to the default ones
#[serde(default)]
Expand Down
1 change: 1 addition & 0 deletions crates/pixi-build-rattler-build/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::path::{Path, PathBuf};
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
pub struct RattlerBuildBackendConfig {
/// If set, internal state will be logged as files in that directory
#[serde(alias = "debug_dir")]
pub debug_dir: Option<PathBuf>,
/// Extra input globs to include in addition to the default ones
#[serde(default)]
Expand Down
18 changes: 18 additions & 0 deletions crates/pixi-build-rust/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct RustBackendConfig {
#[serde(default)]
pub env: IndexMap<String, String>,
/// If set, internal state will be logged as files in that directory
#[serde(alias = "debug_dir")]
pub debug_dir: Option<PathBuf>,
/// Extra input globs to include in addition to the default ones
#[serde(default)]
Expand Down Expand Up @@ -95,6 +96,23 @@ mod tests {
serde_json::from_value::<RustBackendConfig>(json_data).unwrap();
}

#[test]
fn test_debug_dir_accepts_both_formats() {
// Test with debug-dir (kebab-case) - the canonical format
let json_with_hyphen = json!({
"debug-dir": "/path/to/debug"
});
let config = serde_json::from_value::<RustBackendConfig>(json_with_hyphen).unwrap();
assert_eq!(config.debug_dir, Some(PathBuf::from("/path/to/debug")));

// Test with debug_dir (underscore) - should also work due to alias
let json_with_underscore = json!({
"debug_dir": "/path/to/debug"
});
let config = serde_json::from_value::<RustBackendConfig>(json_with_underscore).unwrap();
assert_eq!(config.debug_dir, Some(PathBuf::from("/path/to/debug")));
}

#[test]
fn test_merge_with_target_config() {
let mut base_env = indexmap::IndexMap::new();
Expand Down
5 changes: 3 additions & 2 deletions py-pixi-build-backend/src/types/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};

use pixi_build_backend::generated_recipe::BackendConfig;
use pyo3::{Py, PyAny, Python, pyclass, pymethods};
use pyo3::{pyclass, pymethods, Py, PyAny, Python};
use pythonize::pythonize;
use serde::Deserialize;
use serde::Deserializer;
Expand All @@ -26,9 +26,10 @@ impl<'de> Deserialize<'de> for PyBackendConfig {
Python::attach(|py| {
let model = pythonize(py, &data).map_err(serde::de::Error::custom)?;

// Support both debug_dir and debug-dir
let debug_dir: Option<PathBuf> = data
.as_object_mut()
.and_then(|obj| obj.get("debug_dir"))
.and_then(|obj| obj.get("debug-dir").or_else(|| obj.get("debug_dir")))
.and_then(|v| v.as_str().map(PathBuf::from));

Ok(PyBackendConfig {
Expand Down
Loading