Registry / devops / colcon-library-path

colcon-library-path

JSON →
library0.2.1pypypiunverified

colcon-library-path is an extension for the colcon build system (commonly used in ROS 2 projects) that automatically adds the build and install directories of built libraries to the COLCON_LIBRARY_PATH environment variable. This helps downstream packages locate dependencies. It is currently at version 0.2.1 and appears to be in a maintenance phase, with a stable feature set and infrequent updates.

pip install colcon-library-path
INSTALL
IMPORT
SIG · COLCON-LIBRARY-PAT
C
colcon-library-path
devopspythonv0.2.1
Install
5.0s avg
Import
—
Disk
40MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.1 · 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.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 37.4MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 5.0s · import 0.000s · 38MB
40MB installed
● package 40MB
Code
Verified usage

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

PackageIdentificationExtension
✓ from colcon_library_path.package_identification import PackageIdentificationExtension
✗ from colcon_library_path import PackageIdentificationExtension

This quickstart demonstrates the effect of `colcon-library-path` by programmatically (via `subprocess`) running a `colcon build` command with the `--add-build-paths` option. It then simulates sourcing the generated `setup.bash` file and prints the `COLCON_LIBRARY_PATH` environment variable, showing how the extension contributes library paths. Note that `colcon-library-path` is primarily a CLI extension for `colcon` and is not typically used for direct programmatic Python imports.

import subprocess import os import shutil # --- Setup: Create a dummy colcon workspace and package --- # This part simulates typical shell commands for setting up a colcon project. workspace_path = "my_colcon_workspace" os.makedirs(f"{workspace_path}/src/my_library", exist_ok=True) with open(f"{workspace_path}/src/my_library/CMakeLists.txt", "w") as f: f.write("project(my_library NONE)\n") f.write("add_library(my_library SHARED my_library.cpp)\n") with open(f"{workspace_path}/src/my_library/my_library.cpp", "w") as f: f.write("// dummy C++ file\nint main() { return 0; }") print(f"Created dummy package in {workspace_path}/src/my_library") # --- Step 1: Run colcon build with --add-build-paths --- # This activates the colcon-library-path extension. try: print("\nRunning colcon build with --add-build-paths...") # Ensure colcon is in PATH, otherwise specify full path to colcon executable result = subprocess.run( ['colcon', 'build', '--cmake-args', '-DBUILD_SHARED_LIBS=ON', '--packages-select', 'my_library', '--add-build-paths'], cwd=workspace_path, check=True, capture_output=True, text=True ) print("colcon build stdout:\n" + result.stdout) if result.stderr: print("colcon build stderr:\n" + result.stderr) except FileNotFoundError: print("Error: 'colcon' command not found. Please install colcon (pip install colcon-common-extensions).") # Cleanup before exiting shutil.rmtree(workspace_path) exit(1) except subprocess.CalledProcessError as e: print(f"Error during colcon build:\n{e.stderr}") # Cleanup before exiting shutil.rmtree(workspace_path) exit(1) # --- Step 2: Source the generated setup file and check COLCON_LIBRARY_PATH --- # This demonstrates the effect of colcon-library-path on the environment. setup_file_path = os.path.join(workspace_path, "install", "setup.bash") if os.path.exists(setup_file_path): print(f"\nSourcing {setup_file_path} and checking COLCON_LIBRARY_PATH...") # Simulate sourcing in a new shell to get the environment variable command = f"source {setup_file_path} && echo $COLCON_LIBRARY_PATH" result_env = subprocess.run( ['bash', '-c', command], check=True, capture_output=True, text=True ) colcon_lib_path = result_env.stdout.strip() print(f"COLCON_LIBRARY_PATH after setup: {colcon_lib_path}") if f"{workspace_path}/install/my_library/lib" in colcon_lib_path or \ f"{workspace_path}/build/my_library" in colcon_lib_path: print("\u2705 colcon-library-path successfully contributed to COLCON_LIBRARY_PATH.") else: print("\u274c COLCON_LIBRARY_PATH does not contain expected library paths.") else: print(f"\u274c Error: {setup_file_path} not found. Build might have failed or not produced a setup file.") # --- Cleanup --- print(f"\nCleaning up workspace: {workspace_path}") shutil.rmtree(workspace_path)
Debug
Known issues
gotchaThe `COLCON_LIBRARY_PATH` environment variable, managed by this extension, is primarily used by colcon's internal environment setup (e.g., in `setup.bash`/`setup.ps1`). It does not directly modify system-wide library search paths like `LD_LIBRARY_PATH` on Linux or `PATH` on Windows. You must source the `install/setup.*` file to activate it in your current shell.
fix
Always source the `install/setup.bash` (or equivalent for your shell) file in your terminal after a `colcon build` to make the library paths available for subsequent commands or packages.
affects: All versions
gotchaThe `colcon-library-path` extension is only active when specific `colcon build` options are used, primarily `--add-build-paths` or `--library-path`. Without these options, the extension will not modify `COLCON_LIBRARY_PATH`.
fix
Ensure you explicitly add `--add-build-paths` to your `colcon build` command to enable this extension's functionality. For specific path additions, use `--library-path 'PKG_NAME:PATH'`.
affects: All versions
gotchaIf you are migrating from older build systems or have complex environment setups, ensure that `COLCON_LIBRARY_PATH` is not being inadvertently overridden or cleared by other environment scripts. The ordering of environment file sourcing matters.
fix
Inspect your shell's startup files (e.g., `.bashrc`, `.profile`) and any other `setup.*` files you source to ensure that `colcon`'s environment setup (and thus `COLCON_LIBRARY_PATH`) is applied correctly and not undone by subsequent commands.
affects: All versions
Upgrade
Version history
0.2.1latest on PyPI · released Jan 16, 2019
Audit
Dependencies
colcon-corerequiredThis package is a colcon extension and requires colcon-core to function.
colcon-package-informationrequiredRequired for package information processing within colcon.
Agent activity
37 hits · last 30 days
node
34
OpenAI (training)
1
Resources