Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Loading