6.3. Python Install Modes
The Python package (python/l4yaml) is pure Python over ctypes,
so it has no compile step — only an install step.
The CMake driver supports three install paradigms, picked by the
L4YAML_PYTHON_INSTALL option:
-
ament— usesament_cmake_pythonfrom a sourced ROS 2 environment. Installs the package at${prefix}/lib/pythonX.Y/site-packages/l4yaml/; colcon'ssetup.bashautomatically prepends that path toPYTHONPATH. This is the right mode for a ROS 2 / colcon workflow. -
venv— runspip install -e pythonfrom${L4YAML_PYTHON_VENV}/bin/pythonat configure time. The install is editable, so source edits inpython/l4yaml/take effect without re-running CMake. -
none— CMake does not touch Python; the user installs the package manually withpip install pythonor equivalent.
The default auto mode picks ament when ament_cmake_python is
on the CMake prefix path (i.e. a ROS underlay is sourced), venv
when L4YAML_PYTHON_VENV is set, otherwise none.
The same colcon build command therefore works in both a ROS shell
(uses ament) and a plain dev shell (falls back to none),
without flag changes.
6.3.1. ROS 2 / colcon
In a colcon workspace with a ROS underlay sourced, no additional flags are needed:
source /opt/ros/jazzy/setup.bash colcon build --packages-select L4YAML
After build, source the workspace overlay (. install/setup.bash)
and import l4yaml works.
6.3.2. venv (non-ROS)
For local development outside ROS, point the CMake driver at a venv:
python -m venv .venv && . .venv/bin/activate
cmake -B build -S . \
-DL4YAML_PYTHON_INSTALL=venv \
-DL4YAML_PYTHON_VENV=$VIRTUAL_ENV
cmake --build build -j
The pip install -e python runs at configure time and the venv
keeps tracking python/l4yaml/ thereafter.