Skip to content

Commit 0ece7a5

Browse files
authored
Add configurable ROS package naming (#104)
1 parent ee9f94d commit 0ece7a5

19 files changed

Lines changed: 675 additions & 151 deletions

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ The tool generates `conda` rattler-build recipes to capture all the selected ROS
1313

1414
The repo contains a `vinca` tool that reads a `vinca.yaml` file that contains all its metadata.
1515

16-
For an up-to-date example of how to write a `vinca.yaml`, check the repos of the mantained RoboStack distros:
16+
For an up-to-date example of how to write a `vinca.yaml`, check the repos of the maintained RoboStack distros:
1717
* https://github.com/RoboStack/ros-noetic/
1818
* https://github.com/RoboStack/ros-humble
1919
* https://github.com/RoboStack/ros-jazzy/
20+
21+
## Package naming
22+
23+
The optional `package_name_mode` setting controls the transition from legacy distro-qualified names such as `ros-humble-rclcpp` to ROS-major-version names such as `ros2-rclcpp`:
24+
25+
* `legacy` (default): generate only distro-qualified package names.
26+
* `both`: generate the new names and compatibility packages under the legacy names. Each compatibility package depends on the corresponding new package at the same version.
27+
* `new`: generate only the new names.
28+
29+
Existing configurations remain on `legacy` when this setting is omitted. To start migrating a distribution to the new names, use:
30+
31+
```yaml
32+
package_name_mode: both
33+
```
34+
35+
Once users and downstream projects have migrated, switch to `new` to stop generating the compatibility packages. New ROS 1 package names use the `ros-` prefix; new ROS 2 package names use `ros2-`.

vinca/distro.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ def get_release_package_xml(self, pkg_name):
181181
def check_ros1(self):
182182
return self._distribution_type == "ros1"
183183

184+
def get_ros_version(self):
185+
"""Get ROS version number (1 or 2)"""
186+
return "1" if self.check_ros1() else "2"
187+
188+
def get_package_prefix(self):
189+
"""Get the package name prefix (ros for ROS1, ros2 for ROS2)."""
190+
return "ros" if self.check_ros1() else "ros2"
191+
192+
def get_legacy_package_prefix(self):
193+
"""Get the legacy distro-qualified package name prefix."""
194+
return f"ros-{self.name}"
195+
184196
def get_python_version(self):
185197
return self._python_version
186198

vinca/generate_azure.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from rich import print
1212

13-
from vinca.utils import get_repodata
13+
from vinca.utils import extract_dependency_names, get_repodata
1414
from vinca.utils import literal_unicode as lu
1515
from vinca.distro import Distro
1616
from vinca.main import (
@@ -452,11 +452,9 @@ def main():
452452
"host", []
453453
) + pkg["requirements"].get("run", [])
454454

455-
# sort out requirements that are not built in this run
455+
# Normalize direct and conditional requirements to package names.
456456
for pkg_name, reqs in requirements.items():
457-
requirements[pkg_name] = [
458-
r.split()[0] for r in reqs if (isinstance(r, str) and r in reqs)
459-
]
457+
requirements[pkg_name] = extract_dependency_names(reqs)
460458

461459
G = nx.DiGraph()
462460
for pkg, reqs in requirements.items():

vinca/generate_gha.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from rich import print
1212

13-
from vinca.utils import get_repodata, NoAliasDumper
13+
from vinca.utils import extract_dependency_names, get_repodata, NoAliasDumper
1414
from vinca.utils import literal_unicode as lu
1515
from vinca.distro import Distro
1616
from vinca.main import (
@@ -500,15 +500,9 @@ def main():
500500
"host", []
501501
) + req_section.get("run", [])
502502

503-
# sort out requirements that are not built in this run
503+
# Normalize direct and conditional requirements to package names.
504504
for pkg_name, reqs in requirements.items():
505-
requirements[pkg_name] = [
506-
r.split()[0] for r in reqs if (isinstance(r, str) and r in reqs)
507-
]
508-
if platform == "emscripten-wasm32":
509-
# Hot fix to add the only ros package inside a if else statement
510-
if "ros-humble-rmw-wasm-cpp" in str(reqs):
511-
requirements[pkg_name].append("ros-humble-rmw-wasm-cpp")
505+
requirements[pkg_name] = extract_dependency_names(reqs)
512506

513507
G = nx.DiGraph()
514508
for pkg, reqs in requirements.items():

vinca/generate_gitlab.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import sys
55
import os
66

7+
from vinca.utils import extract_dependency_names
8+
79
try:
810
from yaml import CLoader as Loader, CDumper as Dumper
911
except ImportError:
@@ -41,26 +43,26 @@ def main():
4143
requirements = {}
4244

4345
for pkg in metas:
44-
requirements[pkg["package"]["name"]] = (
45-
pkg["requirements"]["host"] + pkg["requirements"]["run"]
46+
requirement_section = pkg.get("requirements", {})
47+
requirements[pkg["package"]["name"]] = extract_dependency_names(
48+
requirement_section.get("host", []) + requirement_section.get("run", [])
4649
)
4750

4851
print(requirements)
4952

5053
G = nx.DiGraph()
5154
for pkg, reqs in requirements.items():
5255
G.add_node(pkg)
53-
for r in reqs:
54-
if r.startswith("ros-"):
55-
G.add_edge(pkg, r)
56+
for requirement in reqs:
57+
if requirement.startswith(("ros-", "ros2-")):
58+
G.add_edge(pkg, requirement)
5659

5760
# import matplotlib.pyplot as plt
5861
# nx.draw(G, with_labels=True, font_weight='bold')
5962
# plt.show()
6063

6164
tg = list(reversed(list(nx.topological_sort(G))))
6265
print(tg)
63-
print(requirements["ros-melodic-ros-core"])
6466

6567
stages = []
6668
current_stage = []

0 commit comments

Comments
 (0)