colcon-package-information

0.4.1 · active · verified Fri Apr 17

colcon-package-information is an extension for the `colcon` build tool, providing the `info` verb. It allows users to inspect and display various details about packages within a `colcon` workspace, such as their source, version, and dependencies. The current version is 0.4.1, and it follows the stable release cadence of the `colcon` ecosystem, with updates typically coinciding with major `colcon-core` releases or bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install and use `colcon-package-information` via the `colcon` command-line interface. It creates a temporary `colcon` workspace with a dummy package, then executes `colcon info` to display the package's metadata. This highlights the primary interaction model, which is through the `colcon` CLI, not direct Python imports.

import os
import shutil

# Ensure colcon-core and colcon-package-information are installed
os.system("pip install colcon-core colcon-package-information")

workspace_path = "my_colcon_workspace"
package_path = os.path.join(workspace_path, "src", "my_package")

# Create a dummy colcon workspace and a simple package
os.makedirs(package_path, exist_ok=True)

package_xml_content = """
<package format='3'>
  <name>my_package</name>
  <version>0.1.0</version>
  <description>A dummy package for colcon info demonstration.</description>
  <maintainer email='dev@example.com'>Developer</maintainer>
  <license>Apache-2.0</license>
</package>
"""

with open(os.path.join(package_path, "package.xml"), "w") as f:
    f.write(package_xml_content)

print(f"\nCreated dummy workspace at: {workspace_path}")
print(f"Created dummy package 'my_package' at: {package_path}")

# Navigate into the workspace for colcon to find it
original_cwd = os.getcwd()
os.chdir(workspace_path)

# Run the colcon info command
print("\n--- Running colcon info for 'my_package' ---")
os.system("colcon info --packages-select my_package")

print("\n--- Running colcon info for all packages (if more existed) ---")
os.system("colcon info")

# Clean up
os.chdir(original_cwd)
shutil.rmtree(workspace_path)
print(f"\nCleaned up dummy workspace: {workspace_path}")

view raw JSON →