From ec69ef82c330e52496bb11a60004a9d06a80ae0b Mon Sep 17 00:00:00 2001 From: Ezra Brooks Date: Fri, 6 Nov 2026 10:19:12 -0700 Subject: [PATCH] Build the compatibility packages as noarch: generic A ros-- package only depends on ros2- and the mutex, so one noarch build serves every platform. get_channel_records reads the channel's noarch subdir too, so skip_existing finds them once published. --- vinca/naming.py | 2 +- vinca/test_naming_scheme.py | 2 +- vinca/test_utils.py | 19 +++++++++++++++++++ vinca/utils.py | 24 ++++++++++++++++-------- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/vinca/naming.py b/vinca/naming.py index e6dcaa8..e96efd0 100644 --- a/vinca/naming.py +++ b/vinca/naming.py @@ -92,7 +92,7 @@ def generate_legacy_compatibility_output(output, pkg_shortname, distro, vinca_co run.append(mutex_dependency) return { "package": {"name": legacy_name, "version": version}, - "build": {"script": ""}, + "build": {"script": "", "noarch": "generic"}, "requirements": {"run": run}, "about": {"summary": f"Compatibility package for {canonical_name}"}, } diff --git a/vinca/test_naming_scheme.py b/vinca/test_naming_scheme.py index 32c939d..f1f8c0d 100644 --- a/vinca/test_naming_scheme.py +++ b/vinca/test_naming_scheme.py @@ -244,7 +244,7 @@ def test_both_mode_generates_legacy_compatibility_output(): assert compatibility_output == { "package": {"name": "ros-humble-my-package", "version": "1.2.3"}, - "build": {"script": ""}, + "build": {"script": "", "noarch": "generic"}, "requirements": {"run": ["ros2-my-package ==1.2.3"]}, "about": {"summary": "Compatibility package for ros2-my-package"}, } diff --git a/vinca/test_utils.py b/vinca/test_utils.py index 2cf2900..24e3b83 100644 --- a/vinca/test_utils.py +++ b/vinca/test_utils.py @@ -206,3 +206,22 @@ def test_additional_info_by_ros_or_conda_name(name): def test_additional_info_of_a_package_without_an_entry(): assert get_pkg_additional_info("ros2-rclcpp", ADDITIONAL_INFO_CONF) == {} assert get_pkg_additional_info("rclcpp", {"_pkg_additional_info": None}) == {} + + +def test_get_channel_records_includes_the_noarch_subdir(channel): + compat = {**FOO, "name": "ros-lyrical-foo", "build": "h0_31"} + _write_repodata(channel, "noarch", _repodata(compat)) + _write_repodata(channel, "linux-64", _repodata(FOO)) + + assert _names_and_builds(get_channel_records(str(channel), "linux-64")) == [ + ("ros2-foo", "1.0", "h1_31", 31), + ("ros-lyrical-foo", "1.0", "h0_31", 31), + ] + + +def test_get_channel_records_without_a_noarch_subdir(channel): + _write_repodata(channel, "linux-64", _repodata(FOO)) + + assert _names_and_builds(get_channel_records(str(channel), "linux-64")) == [ + ("ros2-foo", "1.0", "h1_31", 31) + ] diff --git a/vinca/utils.py b/vinca/utils.py index 3238bf7..7d88526 100644 --- a/vinca/utils.py +++ b/vinca/utils.py @@ -49,14 +49,14 @@ def _channel(location): return rattler.Channel(str(Path(location).resolve())) -def get_channel_records(channel, platform): - """The package records of *channel*, a URL or local path, for *platform*, as - repodata.json records; none if the channel has no valid repodata for it.""" +def _subdir_records(channel, subdir): + """The package records of *channel*'s *subdir*, as repodata.json records; none + if the channel has no valid repodata for it.""" try: [repodata] = asyncio.run( rattler.fetch_repo_data( channels=[_channel(channel)], - platforms=[rattler.Subdir(platform)], + platforms=[rattler.Subdir(subdir)], cache_path=REPODATA_CACHE, callback=None, ) @@ -66,19 +66,27 @@ def get_channel_records(channel, platform): # network failures raise the same type if not str(exc).startswith("repodata not found"): raise - print( - f"No {platform} repodata found at {channel}, assuming no existing packages" - ) + print(f"No {subdir} repodata found at {channel}, assuming no existing packages") return [] except OSError: print( - f"No valid {platform} repodata found at {channel}, " + f"No valid {subdir} repodata found at {channel}, " "assuming no existing packages" ) return [] return [json.loads(record.to_json()) for record in records] +def get_channel_records(channel, platform): + """The package records of *channel*, a URL or local path, for *platform*: those + of its platform and noarch subdirs.""" + return [ + record + for subdir in (platform, "noarch") + for record in _subdir_records(channel, subdir) + ] + + def ensure_name_is_without_distro_prefix_and_with_underscores(name, vinca_conf): """Normalize new and legacy ROS package names to their ROS package name.""" newname = name.replace("-", "_")