Skip to content

Commit 4b866a6

Browse files
authored
fix: some misc backend issues (#426)
1 parent 74637c1 commit 4b866a6

File tree

15 files changed

+56
-16
lines changed

15 files changed

+56
-16
lines changed

backends/pixi-build-ros/src/pixi_build_ros/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class ROSBackendConfig(pydantic.BaseModel, extra="forbid", arbitrary_types_allow
7171
# Environment variables to set during the build
7272
env: dict[str, str] | None = None
7373
# Directory for debug files of this script
74-
debug_dir: Path | None = pydantic.Field(default=None, alias="debug-dir")
74+
debug_dir: Path | None = pydantic.Field(
75+
default=None, validation_alias=pydantic.AliasChoices("debug-dir", "debug_dir")
76+
)
7577
# Extra input globs to include in the build hash
7678
extra_input_globs: list[str] | None = pydantic.Field(default=None, alias="extra-input-globs")
7779

backends/pixi-build-ros/src/pixi_build_ros/metadata_provider.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class PackageXmlMetadataProvider(MetadataProvider): # type: ignore[misc] # Met
4747
def __init__( # type: ignore[no-untyped-def] # no typing for args and kwargs
4848
self,
4949
package_xml_path: str,
50+
manifest_root: str,
5051
*args,
5152
extra_input_globs: list[str] | None = None,
5253
package_mapping_files: list[str] | None = None,
@@ -57,11 +58,13 @@ def __init__( # type: ignore[no-untyped-def] # no typing for args and kwargs
5758
5859
Args:
5960
package_xml_path: Path to the package.xml file
61+
manifest_root: Path to the manifest root directory
6062
extra_input_globs: Additional glob patterns to include
6163
package_mapping_files: Package mapping file paths to track as inputs
6264
"""
6365
super().__init__(*args, **kwargs)
6466
self.package_xml_path = package_xml_path
67+
self.manifest_root = manifest_root
6568
self._package_data: PackageData | None = None
6669
self._extra_input_globs = list(extra_input_globs or [])
6770
self._package_mapping_files = list(package_mapping_files or [])
@@ -148,8 +151,9 @@ def license(self) -> str | None:
148151
return None
149152

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

154158
def summary(self) -> str | None:
155159
"""Return the description as summary from package.xml."""
@@ -189,6 +193,7 @@ class ROSPackageXmlMetadataProvider(PackageXmlMetadataProvider):
189193
def __init__(
190194
self,
191195
package_xml_path: str,
196+
manifest_root: str,
192197
distro_name: str | None = None,
193198
*,
194199
extra_input_globs: list[str] | None = None,
@@ -199,12 +204,14 @@ def __init__(
199204
200205
Args:
201206
package_xml_path: Path to the package.xml file
207+
manifest_root: Path to the manifest root directory
202208
distro_name: ROS distro. If None, will use the base package name without distro prefix.
203209
extra_input_globs: Additional glob patterns to include
204210
package_mapping_files: Package mapping file paths to track as inputs
205211
"""
206212
super().__init__(
207213
package_xml_path,
214+
manifest_root=manifest_root,
208215
extra_input_globs=extra_input_globs,
209216
package_mapping_files=package_mapping_files,
210217
)

backends/pixi-build-ros/src/pixi_build_ros/ros_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def generate_recipe(
5454
package_mapping_files = [str(path) for path in backend_config.get_package_mapping_file_paths()]
5555
metadata_provider = ROSPackageXmlMetadataProvider(
5656
str(package_xml_path),
57+
str(manifest_root),
5758
backend_config.distro.name,
5859
extra_input_globs=list(backend_config.extra_input_globs or []),
5960
package_mapping_files=package_mapping_files,

backends/pixi-build-ros/templates/build_catkin.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ if [ "${PKG_NAME}" == "ros-noetic-catkin" ]; then
1414
CATKIN_BUILD_BINARY_PACKAGE="OFF"
1515
fi
1616

17-
rm -rf build
18-
mkdir build
17+
mkdir -p build
1918
cd build
2019

2120
# necessary for correctly linking SIP files (from python_qt_bindings)

backends/pixi-build-ros/tests/__snapshots__/test_package_xml.ambr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
about:
125125
homepage: https://test.io/custom_ros
126126
license: LicenseRef-Apache License 2.0
127-
license_file: package.xml
127+
license_file: null
128128
summary: Demo
129129
description: Demo
130130
documentation: null

backends/pixi-build-ros/tests/__snapshots__/test_version_constraints.ambr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
about:
6969
homepage: null
7070
license: LicenseRef-Apache License 2.0
71-
license_file: package.xml
71+
license_file: null
7272
summary: Demo
7373
description: Demo
7474
documentation: null
@@ -145,7 +145,7 @@
145145
about:
146146
homepage: null
147147
license: LicenseRef-Apache License 2.0
148-
license_file: package.xml
148+
license_file: null
149149
summary: Demo
150150
description: Demo
151151
documentation: null
@@ -222,7 +222,7 @@
222222
about:
223223
homepage: null
224224
license: LicenseRef-Apache License 2.0
225-
license_file: package.xml
225+
license_file: null
226226
summary: Demo
227227
description: Demo
228228
documentation: null

backends/pixi-build-ros/tests/test_meta_data_provider.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,35 @@
1010
def test_metadata_provider(package_xmls: Path):
1111
"""Test the MetaDataProvider class."""
1212
package_xml_path = package_xmls / "custom_ros.xml"
13-
metadata_provider = PackageXmlMetadataProvider(str(package_xml_path))
13+
metadata_provider = PackageXmlMetadataProvider(str(package_xml_path), str(package_xmls))
1414
assert metadata_provider.name() == "custom_ros"
1515
assert metadata_provider.version() == "0.0.1"
1616
assert metadata_provider.license() == "LicenseRef-Apache License 2.0"
1717
assert metadata_provider.description() == "Demo"
1818
assert metadata_provider.homepage() == "https://test.io/custom_ros"
1919
assert metadata_provider.repository() == "https://github.com/test/custom_ros"
20+
assert metadata_provider.license_file() is None
2021

2122

2223
def test_ros_metadata_provider(package_xmls: Path):
2324
"""Test the RosMetaDataProvider class."""
2425
package_xml_path = package_xmls / "custom_ros.xml"
25-
metadata_provider = ROSPackageXmlMetadataProvider(str(package_xml_path), distro_name="noetic")
26+
metadata_provider = ROSPackageXmlMetadataProvider(str(package_xml_path), str(package_xmls), distro_name="noetic")
2627
assert metadata_provider.name() == "ros-noetic-custom-ros"
2728
assert metadata_provider.version() == "0.0.1"
2829
assert metadata_provider.license() == "LicenseRef-Apache License 2.0"
2930
assert metadata_provider.description() == "Demo"
3031
assert metadata_provider.homepage() == "https://test.io/custom_ros"
3132
assert metadata_provider.repository() == "https://github.com/test/custom_ros"
33+
assert metadata_provider.license_file() is None
3234

3335

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

3840
with pytest.raises(RuntimeError) as exc_info:
39-
ROSPackageXmlMetadataProvider(str(broken_xml_path), distro_name="noetic")
41+
ROSPackageXmlMetadataProvider(str(broken_xml_path), str(package_xmls), distro_name="noetic")
4042

4143
# Verify the exception contains location information
4244
error = exc_info.value
@@ -85,6 +87,7 @@ def test_metadata_provider_includes_package_mapping_files_in_input_globs():
8587
# Create metadata provider
8688
metadata_provider = ROSPackageXmlMetadataProvider(
8789
str(package_xml_path),
90+
str(temp_path),
8891
distro_name="noetic",
8992
package_mapping_files=package_mapping_files,
9093
)

crates/pixi-build-backend/src/intermediate_backend.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ impl<T: GenerateRecipe> IntermediateBackend<T> {
113113
(source_dir, manifest_rel_path)
114114
}
115115
Some(source_dir) => {
116-
let manifest_rel_path = pathdiff::diff_paths(manifest_path, &source_dir)
116+
let manifest_rel_path = pathdiff::diff_paths(&manifest_path, &source_dir)
117117
.ok_or_else(|| {
118-
miette::miette!("the manifest is not relative to the source directory")
118+
miette::miette!(
119+
"the manifest: {} is not relative to the source directory: {}",
120+
manifest_path.display(),
121+
source_dir.display()
122+
)
119123
})?;
120124
(source_dir, manifest_rel_path)
121125
}

crates/pixi-build-backend/tests/integration/protocol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod imp {
2626
#[serde(rename_all = "kebab-case")]
2727
pub struct TestBackendConfig {
2828
/// If set, internal state will be logged as files in that directory
29+
#[serde(alias = "debug_dir")]
2930
pub debug_dir: Option<PathBuf>,
3031
}
3132

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct CMakeBackendConfig {
1414
#[serde(default)]
1515
pub env: IndexMap<String, String>,
1616
/// If set, internal state will be logged as files in that directory
17+
#[serde(alias = "debug_dir")]
1718
pub debug_dir: Option<PathBuf>,
1819
/// Extra input globs to include in addition to the default ones
1920
#[serde(default)]

0 commit comments

Comments
 (0)