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_test → isaac_ros_test/build/version_info.yaml
isaac_ros_launch_utils → isaac_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
- Clone
isaac_ros_common into a colcon workspace.
colcon build --packages-select isaac_ros_test isaac_ros_launch_utils
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)
version_info.yamlis written into the source tree forament_pythonpackagesSummary
For
ament_pythonpackages,GenerateVersionInfoCommandwritesversion_info.yamlinto the source directory (<source>/build/version_info.yaml) instead of the colcon build space. Everycolcon buildtherefore 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_pythonpackages whosesetup.pyusesGenerateVersionInfoCommand, e.g.:isaac_ros_test→isaac_ros_test/build/version_info.yamlisaac_ros_launch_utils→isaac_ros_launch_utils/build/version_info.yamlisaac_common_pyCMake packages are not affected — their
generate_version_info()macro writes toCMAKE_BINARY_DIR, which is correctly out-of-source.Root cause
isaac_ros_common/scripts/isaac_ros_common-version-info.py, ingenerate_version_info():When colcon builds an
ament_pythonpackage it invokessetup.pywith cwd = the package source directory, soos.getcwd()/buildresolves inside the source tree. The output path ignores the build base that setuptools already provides.Expected behavior
version_info.yamlshould be generated in the build directory (as the CMake path already does) and not modify the source tree.Suggested fix
GenerateVersionInfoCommandsubclasses setuptools'build_py, which already exposes the correct out-of-source build directory asself.build_lib. Thread it through:The file still gets installed to
share/<package>viadata_files, but is no longer written into the source tree.Steps to reproduce
isaac_ros_commoninto a colcon workspace.colcon build --packages-select isaac_ros_test isaac_ros_launch_utilsgit statusin the source tree → untrackedisaac_ros_test/build/version_info.yamlandisaac_ros_launch_utils/build/version_info.yaml.Environment
0eb5434c695cc649a501428876380c3e371dbc00, release-4.2)ament_pythonbuild type)