colcon-package-selection
colcon-package-selection is an extension for colcon, a build tool primarily used in the Robot Operating System (ROS) ecosystem, to allow users to precisely select which packages should be processed during build, test, or install operations. It enhances colcon's core functionality by providing command-line arguments for including or excluding packages based on names or dependencies. The current version is 0.2.10. It follows the colcon core release cadence, typically tied to ROS releases or when new features/fixes are required.
Common errors
-
colcon: error: argument --packages-select: unrecognized arguments: my_package
cause The `colcon-package-selection` extension is not installed or not discoverable by `colcon`.fixInstall the extension using `pip install colcon-package-selection`. -
--- stderr: my_package_name` (followed by build failure due to missing dependencies)
cause The user used `--packages-select` expecting recursive dependencies to be built, but only the specified package was processed.fixIf dependencies need to be built, use `colcon build --packages-up-to my_package_name` instead of `--packages-select`. -
[WARN] Some packages were not found in the workspace: 'non_existent_package'
cause The specified package either doesn't exist, is misspelled, or is not correctly discovered by colcon in the current workspace (e.g., missing a `package.xml` or not sourced correctly).fixVerify the package name is correct and the package's `package.xml` is valid. Ensure you are running `colcon` in a valid workspace root or have sourced the workspace's `install/setup.bash` (or similar) if necessary.
Warnings
- gotcha Using `--packages-select` only builds the specified packages, *not* their recursive dependencies. To build a package and all its dependencies, use `--packages-up-to`.
- gotcha Arguments like `--packages-skip` take precedence over `--packages-select`. If a package is both selected and skipped, it will be skipped.
- gotcha When using shell globs (e.g., `colcon build --packages-select 'my_pkg_*'`), be aware that your shell might expand the glob before `colcon` processes it, potentially leading to incorrect selection or command-line length issues.
Install
-
pip install colcon-package-selection
Imports
- colcon-package-selection CLI
from colcon_package_selection import some_internal_class
colcon build --packages-select PACKAGE_NAME
Quickstart
colcon build --packages-select my_robot_pkg