Skip to content

Commit 6c94b5b

Browse files
authored
refactor: default to ros-<distro>- prefixed names. (#386)
* refactor: default to `ros-<distro>-` prefixed names. * test: get ros-distro prefix in tests and make them platform independent * test: multi package non ros support
1 parent 475ad36 commit 6c94b5b

File tree

8 files changed

+28
-33
lines changed

8 files changed

+28
-33
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,9 @@ def rosdep_to_conda_package_name(
102102
else:
103103
raise RuntimeError(f"Unsupported platform: {host_platform}")
104104

105-
# If dependency any of the following return custom name:
106-
if dep_name in [
107-
"ament_cmake",
108-
"ament_python",
109-
"rosidl_default_generators",
110-
"ros_workspace",
111-
]:
112-
return [f"ros-{distro.name}-{dep_name.replace('_', '-')}"]
113-
114105
if dep_name not in package_map_data:
115-
# If the dependency is not found in robostack.yaml, check the actual distro whether it exists
116-
if distro.has_package(dep_name):
117-
# This means that it is a ROS package, so we are going to assume has the `ros-<distro>-<dep_name>` format.
118-
return [f"ros-{distro.name}-{dep_name.replace('_', '-')}{spec_str}"]
119-
else:
120-
# If the dependency is not found in robostack.yaml and not in the distro, return the dependency name as is.
121-
return [f"{dep_name}{spec_str}"]
106+
# Package name isn't found in the package map, so we are going to assume it is a ROS package.
107+
return [f"ros-{distro.name}-{dep_name.replace('_', '-')}{spec_str or ''}"]
122108

123109
# Dependency found in package map
124110

@@ -226,7 +212,6 @@ def package_xml_to_conda_requirements(
226212
package_map_data: dict[str, PackageMapEntry],
227213
) -> ConditionalRequirements:
228214
"""Convert a CatkinPackage to ConditionalRequirements for conda."""
229-
230215
# All build related dependencies go into the build requirements
231216
build_deps = pkg.buildtool_depends
232217
# TODO: should the export dependencies be included here?
@@ -270,5 +255,7 @@ def package_xml_to_conda_requirements(
270255
cond.host = build_requirements
271256
cond.build = build_requirements
272257
cond.run = run_requirements
258+
if "navigator" == pkg.name:
259+
raise Exception(cond)
273260

274261
return cond

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
requirements:
1616
build:
1717
- ros-noetic-catkin
18-
- ros_package
18+
- ros-noetic-ros-package
19+
- ros-noetic-multi-package
1920
- ninja
2021
- python
2122
- setuptools
@@ -30,15 +31,17 @@
3031
- ${{ compiler('cxx') }}
3132
host:
3233
- ros-noetic-catkin
33-
- ros_package
34+
- ros-noetic-ros-package
35+
- ros-noetic-multi-package
3436
- python
3537
- numpy
3638
- pip
3739
- pkg-config
3840
- ros-distro-mutex
3941
run:
4042
- rich >=10.0
41-
- ros_package
43+
- ros-noetic-ros-package
44+
- ros-noetic-multi-package
4245
- ros-distro-mutex
4346
run_constraints: []
4447
tests: []

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- xorg-libxext
2222
- ros-noetic-ros-package <=2.0.0
2323
- ros-noetic-ros-package-msgs <=2.0.0
24-
- ros_package2 <2.0.0a0
24+
- ros-noetic-ros-package2 <2.0.0a0
2525
- qt-main >=5.15.0,<5.16.0
2626
- tinyxml2 ==10.0.0
2727
- asio <10.0.0
@@ -45,7 +45,7 @@
4545
- xorg-libxext
4646
- ros-noetic-ros-package <=2.0.0
4747
- ros-noetic-ros-package-msgs <=2.0.0
48-
- ros_package2 <2.0.0a0
48+
- ros-noetic-ros-package2 <2.0.0a0
4949
- qt-main >=5.15.0,<5.16.0
5050
- tinyxml2 ==10.0.0
5151
- asio <10.0.0
@@ -58,7 +58,7 @@
5858
- rich >=10.0
5959
- ros-noetic-ros-package <=2.0.0
6060
- ros-noetic-ros-package-msgs <=2.0.0
61-
- ros_package2 <2.0.0a0
61+
- ros-noetic-ros-package2 <2.0.0a0
6262
- qt-main >=5.15.0,<5.16.0
6363
- tinyxml2 ==10.0.0
6464
- asio <10.0.0
@@ -99,7 +99,7 @@
9999
- xorg-libxext
100100
- ros-noetic-ros-package <=2.0.0
101101
- ros-noetic-ros-package-msgs <=2.0.0
102-
- ros_package2 <2.0.0a0
102+
- ros-noetic-ros-package2 <2.0.0a0
103103
- qt-main >=5.15.0,<5.16.0
104104
- tinyxml2 ==10.0.0
105105
- asio <10.0.0
@@ -123,7 +123,7 @@
123123
- xorg-libxext
124124
- ros-noetic-ros-package <=2.0.0
125125
- ros-noetic-ros-package-msgs <=2.0.0
126-
- ros_package2 <2.0.0a0
126+
- ros-noetic-ros-package2 <2.0.0a0
127127
- qt-main >=5.15.0,<5.16.0
128128
- tinyxml2 ==10.0.0
129129
- asio <10.0.0
@@ -135,7 +135,7 @@
135135
run:
136136
- ros-noetic-ros-package <=2.0.0
137137
- ros-noetic-ros-package-msgs <=2.0.0
138-
- ros_package2 <2.0.0a0
138+
- ros-noetic-ros-package2 <2.0.0a0
139139
- qt-main >=5.15.0,<5.16.0
140140
- tinyxml2 ==10.0.0
141141
- asio <10.0.0
@@ -176,7 +176,7 @@
176176
- xorg-libxext
177177
- ros-noetic-ros-package <=2.0.0
178178
- ros-noetic-ros-package-msgs <=2.0.0
179-
- ros_package2 <2.0.0a0
179+
- ros-noetic-ros-package2 <2.0.0a0
180180
- qt-main >=5.15.0,<5.16.0
181181
- tinyxml2 ==10.0.0
182182
- asio <10.0.0
@@ -200,7 +200,7 @@
200200
- xorg-libxext
201201
- ros-noetic-ros-package <=2.0.0
202202
- ros-noetic-ros-package-msgs <=2.0.0
203-
- ros_package2 <2.0.0a0
203+
- ros-noetic-ros-package2 <2.0.0a0
204204
- qt-main >=5.15.0,<5.16.0
205205
- tinyxml2 ==10.0.0
206206
- asio <10.0.0
@@ -212,7 +212,7 @@
212212
run:
213213
- ros-noetic-ros-package <=2.0.0
214214
- ros-noetic-ros-package-msgs <=2.0.0
215-
- ros_package2 <2.0.0a0
215+
- ros-noetic-ros-package2 <2.0.0a0
216216
- qt-main >=5.15.0,<5.16.0
217217
- tinyxml2 ==10.0.0
218218
- asio >=9.0,<10.0.0,<10.0.0,<10.0.0

backends/pixi-build-ros/tests/data/other_package_map.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ alsa-oss:
22
conda: [other-alsa-oss]
33
new_package:
44
conda: [new-package]
5+
multi_package:
6+
conda: [multi-package-a, multi-package-b]
57
ros_package:
68
ros: [ros_package, ros_package_msgs]

backends/pixi-build-ros/tests/data/package_xmls/custom_ros.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<license>Apache License 2.0</license>
1515
<buildtool_depend>catkin</buildtool_depend>
1616
<depend>ros_package</depend>
17+
<depend>multi_package</depend>
1718
<export>
1819
</export>
1920
</package>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def test_generate_recipe_with_custom_ros(package_xmls: Path, test_data_dir: Path
9292
req_string = list(str(req) for req in generated_recipe.recipe.requirements.run)
9393
assert "ros-noetic-ros-package" in req_string
9494
assert "ros-noetic-ros-package-msgs" in req_string
95+
assert "multi-package-a" in req_string
96+
assert "multi-package-b" in req_string
9597

9698

9799
def test_generate_recipe_with_inline_package_mappings(package_xmls: Path, test_data_dir: Path, distro_noetic: Distro):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_recipe_includes_project_run_dependency(package_xmls: Path, distro: Dist
174174
model = ProjectModelV1.from_json(json.dumps(model_payload))
175175

176176
config = {"distro": "noetic", "noarch": False}
177-
host_platform = Platform.current()
177+
host_platform = Platform("linux-64")
178178
generator = ROSGenerator()
179179

180180
generated_recipe = generator.generate_recipe(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_generate_recipe_with_versions(package_xmls: Path, test_data_dir: Path,
3131
}
3232

3333
# Create host platform
34-
host_platform = Platform.current()
34+
host_platform = Platform("linux-64")
3535

3636
# Create ROSGenerator instance
3737
generator = ROSGenerator()
@@ -85,7 +85,7 @@ def test_generate_recipe_with_mutex_version(package_xmls: Path, test_data_dir: P
8585
model = ProjectModelV1.from_dict(model_payload)
8686

8787
# Create host platform
88-
host_platform = Platform.current()
88+
host_platform = Platform("linux-64")
8989

9090
# Create ROSGenerator instance
9191
generator = ROSGenerator()
@@ -141,7 +141,7 @@ def test_generate_recipe_with_versions_in_model_and_package(
141141
model = ProjectModelV1.from_dict(model_payload)
142142

143143
# Create host platform
144-
host_platform = Platform.current()
144+
host_platform = Platform("linux-64")
145145

146146
# Create ROSGenerator instance
147147
generator = ROSGenerator()

0 commit comments

Comments
 (0)