Skip to content

conditional_python_dependency: count ament_cmake_python as a build tool - #185

Merged
traversaro merged 1 commit into
RoboStack:masterfrom
EzraBrooks:vinca-py/1-buildtool-markers
Nov 4, 2026
Merged

traversaro merged 1 commit into
RoboStack:masterfrom
EzraBrooks:vinca-py/1-buildtool-markers

Conversation

@EzraBrooks

Copy link
Copy Markdown
Contributor

ament_cmake packages install their own Python modules through ament_cmake_python, which they declare as a buildtool_depend. Those were not scanned, so e.g. rosidl_cmake, ament_cmake_test, angles, srdfdom and rosbag2_storage_mcap were built once, with their modules in the site-packages of the build-time Python only.

Scan buildtool_depend/buildtool_export_depend for the known markers (not for any "python" name: a plain python3 build tool stays ignored), and add rosidl_pycommon to the markers (rosidl_generator_rs, ros_gz_bridge).

ament_cmake packages install their own Python modules through
ament_cmake_python, which they declare as a buildtool_depend. Those were
not scanned, so e.g. rosidl_cmake, ament_cmake_test, angles, srdfdom and
rosbag2_storage_mcap were built once, with their modules in the
site-packages of the build-time Python only.

Scan buildtool_depend/buildtool_export_depend for the known markers (not
for any "python" name: a plain python3 build tool stays ignored), and add
rosidl_pycommon to the markers (rosidl_generator_rs, ros_gz_bridge).
@traversaro

Copy link
Copy Markdown
Member

Thanks!

@traversaro
traversaro merged commit 549beb7 into RoboStack:master Nov 4, 2026
3 checks passed
@traversaro

Copy link
Copy Markdown
Member

One agent noted this:

  1. Low priority: inactive build-tool dependencies still trigger Python variants.

The new comprehension in recipes.py, lines 175–183 reads every dependency name without checking dependency.evaluated_condition.

For example:
<buildtool_depend condition="$ROS_VERSION == 1">
ament_cmake_python
</buildtool_depend>

With ROS_VERSION=2, I verified that the dependency evaluates to false, but _package_needs_python() returns true. Consequently, an otherwise C++ package receives Python host/run requirements and unnecessary Python variants.

The existing checks for ordinary dependencies already behave this way, so the PR follows the current conservative approach. I would treat this as a follow-up, not a merge blocker. If detection should respect the selected environment, reuse _evaluated_dependency_names() and address both scans consistently.

This is totally true, but not introduced in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants