build(containers): use native astyle in the ROS images

astyle-py 1.1.0 requires PyYAML~=6.0.1, which conflicts with the distro
PyYAML 5.4.1 that the ROS humble image pins as a pip constraint, so the
image build fails with ResolutionImpossible. Install the distro astyle
(3.1 on jammy and noble, accepted by fix_code_style.sh) and leave
astyle-py out of the requirements installed in the ROS images.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
This commit is contained in:
Andrea Bernasconi committed 2026-11-18 15:28:39 +01:00
1 parent 6e7f78bc70
commit fcf0bb686b
1 file changed
+11 -3
@@ -18,10 +18,18 @@ apt-get install -y --no-install-recommends /ros2-apt-source.deb
rm /ros2-apt-source.deb
apt-get update
apt-get install -y --no-install-recommends \
build-essential ccache cmake git ninja-build \
astyle build-essential ccache cmake git ninja-build \
python3-empy python3-pip ros-dev-tools "ros-${ROS_DISTRO}-ros-base" \
"ros-${ROS_DISTRO}-rmw-zenoh-cpp"
# astyle-py requires PyYAML 6, which conflicts with the distro PyYAML pinned
# below (5.4.1 on jammy). Rely on the distro astyle 3.1 installed above, which
# Tools/astyle/fix_code_style.sh accepts. /px4-setup is a read-only bind mount,
# so filter a copy of it.
px4_setup_dir=$(mktemp -d)
cp -r /px4-setup/. "${px4_setup_dir}"
sed -i '/^astyle-py/d' "${px4_setup_dir}/requirements.txt"
# Keep Ubuntu/ROS Python packages while satisfying PX4's shared requirements.
# Distro-only versions (e.g. ubuntu suffixes) cannot be pip constraints.
python3 - <<'PY' > /px4-python-constraints.txt
@@ -43,8 +51,8 @@ else
extra_args=""
fi
RUNS_IN_DOCKER=true PIP_CONSTRAINT=/px4-python-constraints.txt PIP_NO_CACHE_DIR=1 \
bash /px4-setup/ubuntu.sh --no-nuttx ${extra_args}
rm /px4-python-constraints.txt
bash "${px4_setup_dir}/ubuntu.sh" --no-nuttx ${extra_args}
rm -rf /px4-python-constraints.txt "${px4_setup_dir}"
rosdep init
rosdep update --rosdistro "${ROS_DISTRO}"