Skip to content

version_info.yaml is written into the source tree for ament_python packages #239

Description

@george-pippos-rumata

version_info.yaml is written into the source tree for ament_python packages

Summary

For ament_python packages, GenerateVersionInfoCommand writes version_info.yaml into the source directory (<source>/build/version_info.yaml) instead of the colcon build space. Every colcon build therefore creates/updates files inside the checked-out repo, leaving the working tree (and, when consumed as a git submodule, the parent repo) permanently dirty.

Affected packages

The ament_python packages whose setup.py uses GenerateVersionInfoCommand, e.g.:

  • isaac_ros_testisaac_ros_test/build/version_info.yaml
  • isaac_ros_launch_utilsisaac_ros_launch_utils/build/version_info.yaml
  • isaac_common_py

CMake packages are not affected — their generate_version_info() macro writes to CMAKE_BINARY_DIR, which is correctly out-of-source.

Root cause

isaac_ros_common/scripts/isaac_ros_common-version-info.py, in generate_version_info():

build_dir = os.path.join(os.getcwd(), 'build')
os.makedirs(build_dir, exist_ok=True)
output_path = os.path.join(build_dir, 'version_info.yaml')

When colcon builds an ament_python package it invokes setup.py with cwd = the package source directory, so os.getcwd()/build resolves inside the source tree. The output path ignores the build base that setuptools already provides.

Expected behavior

version_info.yaml should be generated in the build directory (as the CMake path already does) and not modify the source tree.

Suggested fix

GenerateVersionInfoCommand subclasses setuptools' build_py, which already exposes the correct out-of-source build directory as self.build_lib. Thread it through:

# GenerateVersionInfoCommand.run()
output_path, install_destination = generate_version_info(
    project_name, project_path, build_dir=self.build_lib)
# generate_version_info(...)
def generate_version_info(project_name, source_dir, build_dir=None):
    ...
    if build_dir is None:                       # keep old behavior as fallback
        build_dir = os.path.join(os.getcwd(), 'build')
    os.makedirs(build_dir, exist_ok=True)
    output_path = os.path.join(build_dir, 'version_info.yaml')

The file still gets installed to share/<package> via data_files, but is no longer written into the source tree.

Steps to reproduce

  1. Clone isaac_ros_common into a colcon workspace.
  2. colcon build --packages-select isaac_ros_test isaac_ros_launch_utils
  3. git status in the source tree → untracked isaac_ros_test/build/version_info.yaml and isaac_ros_launch_utils/build/version_info.yaml.

Environment

  • Isaac ROS version: 4.2.0 (commit 0eb5434c695cc649a501428876380c3e371dbc00, release-4.2)
  • Build tool: colcon (ament_python build type)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions