Registry / devops / colcon-bash

colcon-bash

JSON →
library0.5.0pypypiunverified

colcon-bash is an extension for the colcon build system, primarily used in robotics development (e.g., ROS 2). It provides the functionality to generate Bash shell scripts (e.g., `setup.bash`) within colcon workspaces. These scripts are crucial for setting up the environment, allowing users to easily source packages and make their executables and libraries discoverable. The current version is 0.5.0, and it follows the colcon project's release cadence, often coinciding with ROS 2 releases or colcon-core updates.

pip install colcon-bash
INSTALL
IMPORT
SIG · COLCON-BASH
C
colcon-bash
devopspythonv0.5.0
Install
6.2s avg
Import
Disk
53MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 49.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 6.2s · import 0.000s · 50MB
53MB installed
● package 53MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PackageBashExtension
from colcon_bash import PackageBashExtension
from colcon_bash import PackageBashExtension

This quickstart demonstrates how `colcon-bash` integrates with `colcon`. After building a package, `colcon-bash` ensures that `install/setup.bash` is generated. Sourcing this script adds package-specific environment variables and PATH entries, allowing executables like `my_executable` to be run directly.

# Create a colcon workspace mkdir -p my_colcon_ws/src cd my_colcon_ws/src # Create a minimal C++ package (CMake) mkdir my_pkg cd my_pkg cat << EOF > CMakeLists.txt cmake_minimum_required(VERSION 3.5) project(my_pkg NONE) add_executable(my_executable my_executable.cpp) EOF cat << EOF > my_executable.cpp #include <iostream> int main() { std::cout << "Hello from my_pkg!" << std::endl; return 0; } EOF cd .. # back to src # Build the workspace using colcon (colcon-bash will generate setup.bash) cd .. # back to my_colcon_ws # Note: ensure colcon-bash is installed (e.g., pip install colcon-common-extensions) colcon build --packages-select my_pkg # Source the generated setup script to make the package discoverable source install/setup.bash # Run the executable from the environment my_executable
Debug
Known issues
gotchacolcon-bash only generates Bash-compatible setup scripts (`setup.bash`). Users of other shells (like Zsh or Fish) will need to install corresponding colcon extensions (e.g., `colcon-zsh`, `colcon-fish`) to get native setup scripts for their shell.
fix
Install `colcon-zsh` for Zsh or `colcon-fish` for Fish, and use `source install/setup.zsh` or `source install/setup.fish` respectively.
affects: All
gotchaSourcing multiple `setup.bash` files (e.g., from different `colcon` workspaces or ROS distributions) can lead to environment variable conflicts or unexpected behavior. The order of sourcing matters, and the last sourced environment typically takes precedence.
fix
Always start with a clean shell or carefully manage your environment. Use `source /opt/ros/{DISTRO}/setup.bash` first (for ROS 2), then your workspace's `source install/setup.bash`. Unset ROS environment variables before switching workspaces if conflicts occur.
affects: All
gotchaAfter running `colcon build`, the new packages, executables, or libraries will not be immediately available in your shell. You must explicitly `source install/setup.bash` in your terminal to update the environment variables (like PATH, LD_LIBRARY_PATH).
fix
Run `source install/setup.bash` from your workspace root directory (`my_colcon_ws` in the quickstart example) to update your environment. Consider adding it to your shell's startup script (`.bashrc`) if it's your primary workspace.
affects: All
Upgrade
Version history
0.5.0latest on PyPI · released Sep 25, 2023
Audit
Dependencies
colcon-corerequiredcolcon-bash is an extension to colcon-core and requires it to function. It is a direct install_requires dependency.
Agent activity
20 hits · last 30 days
node
20
Resources
colcon-bash — pip install colcon-bash · libregistry