colcon-package-information
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
-
colcon: error: argument {build,test,install,package,help}: invalid choice: 'info' (choose from 'build', 'test', 'install', 'package', 'help')cause The `colcon info` verb is not recognized by `colcon`. This typically happens if `colcon-package-information` is not installed, or if `colcon-core` (its primary dependency) is missing or not discoverable by your Python environment.fixEnsure both `colcon-core` and `colcon-package-information` are installed in the active Python environment: `pip install colcon-core colcon-package-information`. Verify `colcon` is in your system's `PATH`. -
ModuleNotFoundError: No module named 'colcon_package_information'
cause Attempting to import `colcon_package_information` directly as a regular Python library for end-user functionality. While the package *can* be imported, its primary purpose is as a `colcon` command-line extension, not a library for direct function calls.fixInstead of importing and calling functions, use the `colcon` command-line tool. For example, run `colcon info` in your terminal. If you need to interact with its output from Python, use `subprocess.run(['colcon', 'info'], capture_output=True)` and parse the result.
Warnings
- gotcha This package is a `colcon` extension and provides a new `colcon` verb (`info`). Its functionality is primarily accessed via the `colcon` command-line interface (e.g., `colcon info`), not by importing Python modules and calling functions directly within Python scripts for end-user tasks.
- gotcha `colcon-package-information` requires `colcon-core` to be installed and available in the environment for the `colcon info` verb to be discovered and function correctly. Installing `colcon-package-information` alone without `colcon-core` will not expose the `info` verb.
Install
-
pip install colcon-package-information
Imports
- InfoVerb
from colcon_package_information.verb.info import InfoVerb
Quickstart
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}")