From 54ebeb24cabdcc74bc6cfb4281573e78dd9f6217 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 13:05:32 +0200 Subject: [PATCH 01/16] Remove libpcl-dev and ros-perception from ros2.txt. To be moved to ros2_extra.txt --- turludock/assets/dockerfile_templates/ros2.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/turludock/assets/dockerfile_templates/ros2.txt b/turludock/assets/dockerfile_templates/ros2.txt index 3a8a36d..ab6d87a 100644 --- a/turludock/assets/dockerfile_templates/ros2.txt +++ b/turludock/assets/dockerfile_templates/ros2.txt @@ -6,9 +6,7 @@ RUN add-apt-repository -y universe && \ RUN apt-get update && apt-get install -y \ ros-$ros_version_short-desktop \ ros-dev-tools \ - ros-$ros_version_short-perception \ - libpcl-dev && \ apt-get clean && rm -rf /var/lib/apt/lists/* RUN echo "source /opt/ros/$ros_version_short/setup.bash" >> /root/.bashrc && \ - echo "source /opt/ros/$ros_version_short/setup.zsh" >> /root/.zshrc \ No newline at end of file + echo "source /opt/ros/$ros_version_short/setup.zsh" >> /root/.zshrc From 69121b630e3f133b133fc0b2632cff133db39c40 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 15:35:34 +0200 Subject: [PATCH 02/16] Add new template file ros2_extra.txt to explicitly define extra ROS packages. Added a few of those as well. --- .../dockerfile_templates/ros2_extra.txt | 15 +++++++ turludock/generate_dockerfile.py | 2 + turludock/generate_templated_files.py | 41 +++++++++++++------ 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100755 turludock/assets/dockerfile_templates/ros2_extra.txt diff --git a/turludock/assets/dockerfile_templates/ros2_extra.txt b/turludock/assets/dockerfile_templates/ros2_extra.txt new file mode 100755 index 0000000..b884eb0 --- /dev/null +++ b/turludock/assets/dockerfile_templates/ros2_extra.txt @@ -0,0 +1,15 @@ +# Extra ROS2 packages +RUN apt-get update && apt-get install -y \ + ros-$ros_version_short-rosbag2-storage-mcap \ + ros-$ros_version_short-perception \ + ros-$ros_version_short-cv-bridge \ + ros-$ros_version_short-pcl-ros \ + ros-$ros_version_short-pcl-conversions \ + ros-$ros_version_short-visualization-msgs \ + ros-$ros_version_short-sensor-msgs \ + ros-$ros_version_short-geometry-msgs \ + libpcl-dev \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache-dir --break-system-packages --upgrade pip || pip install --no-cache-dir --upgrade pip && \ + pip install rosbags \ No newline at end of file diff --git a/turludock/generate_dockerfile.py b/turludock/generate_dockerfile.py index 1806b88..3bf6b9e 100644 --- a/turludock/generate_dockerfile.py +++ b/turludock/generate_dockerfile.py @@ -31,6 +31,7 @@ generate_header_info, generate_llvm, generate_ros, + generate_ros_extra, generate_tmux, ) from turludock.helper_functions import ( @@ -208,6 +209,7 @@ def generate_dockerfile(yaml_config: Dict[str, Any]) -> str: # Add ROS dockerfile += generate_ros(yaml_config["ros_version"]) + dockerfile += generate_ros_extra(yaml_config["ros_version"]) # Add the extra-packages extra_packages_label_list = list() diff --git a/turludock/generate_templated_files.py b/turludock/generate_templated_files.py index d710886..a63132e 100644 --- a/turludock/generate_templated_files.py +++ b/turludock/generate_templated_files.py @@ -13,7 +13,6 @@ get_cpu_count_for_build, get_ros_major_version, get_ubuntu_version, - is_ros_version_supported, is_version_greater, is_version_lower, ) @@ -121,10 +120,6 @@ def generate_header_info(docker_label_description: str, ros_version_short: str) """ logger.debug(f"Generate 'header_info.txt'. Input: {docker_label_description}, {ros_version_short}") - # Check if provided version is supported - if not is_ros_version_supported(ros_version_short): - raise ValueError(f"ROS version '{ros_version_short}' not supported. Check your configuration.") - # Map the template variables mapping = { "docker_label_description": docker_label_description, @@ -199,7 +194,7 @@ def generate_llvm(version: str) -> str: def generate_ros(ros_version_codename: str) -> str: - """Generates the 'ros1.txt' or 'ros2.txt' templated file, which is responsible for installing ROS 1 or 2 + """Generates the 'rosX.txt' templated file, which is responsible for installing ROS 1 or 2 The selection of ROS 1 or 2 is based on the provided ROS codename. @@ -207,10 +202,7 @@ def generate_ros(ros_version_codename: str) -> str: ros_version_codename (str): The ROS version as codename. Returns: - str: The populated 'ros1.txt' file as a string. - - Raises: - ValueError: If the provided ROS version is not supported. + str: The populated 'rosX.txt' file as a string. """ # Determine if it ROS1 or ROS2 if get_ros_major_version(ros_version_codename) == 1: @@ -220,9 +212,32 @@ def generate_ros(ros_version_codename: str) -> str: logger.debug(f"Generate '{template_file}'. Input: {ros_version_codename}") - # Check if provided version is supported - if not is_ros_version_supported(ros_version_codename): - raise ValueError("ROS version not supported. Check your configuration.") + # Map the template variables + mapping = {"ros_version_short": ros_version_codename} + + # Populate the templated file + return populate_templated_file(mapping, template_file) + + +def generate_ros_extra(ros_version_codename: str) -> str: + """Generates the 'rosX_extra.txt' templated file, which is responsible for installing extra ROS packages + + The selection of ROS 1 or 2 is based on the provided ROS codename. + + Args: + ros_version_codename (str): The ROS version as codename. + + Returns: + str: The populated 'rosX_extra.txt' file as a string. + """ + # Determine if it ROS1 or ROS2 + if get_ros_major_version(ros_version_codename) == 1: + # TODO + return "" + else: + template_file = "ros2_extra.txt" + + logger.debug(f"Generate '{template_file}'. Input: {ros_version_codename}") # Map the template variables mapping = {"ros_version_short": ros_version_codename} From a1909d48f01e832aeed2f79c2af90171bb45c4f0 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 16:39:48 +0200 Subject: [PATCH 03/16] Add more ROS2 packages to the ros2_extra.txt file --- turludock/assets/dockerfile_templates/ros2.txt | 2 +- turludock/assets/dockerfile_templates/ros2_extra.txt | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/turludock/assets/dockerfile_templates/ros2.txt b/turludock/assets/dockerfile_templates/ros2.txt index ab6d87a..a2a3ab3 100644 --- a/turludock/assets/dockerfile_templates/ros2.txt +++ b/turludock/assets/dockerfile_templates/ros2.txt @@ -5,7 +5,7 @@ RUN add-apt-repository -y universe && \ RUN apt-get update && apt-get install -y \ ros-$ros_version_short-desktop \ - ros-dev-tools \ + ros-dev-tools && \ apt-get clean && rm -rf /var/lib/apt/lists/* RUN echo "source /opt/ros/$ros_version_short/setup.bash" >> /root/.bashrc && \ diff --git a/turludock/assets/dockerfile_templates/ros2_extra.txt b/turludock/assets/dockerfile_templates/ros2_extra.txt index b884eb0..c25937c 100755 --- a/turludock/assets/dockerfile_templates/ros2_extra.txt +++ b/turludock/assets/dockerfile_templates/ros2_extra.txt @@ -1,14 +1,23 @@ # Extra ROS2 packages RUN apt-get update && apt-get install -y \ + ros-$ros_version_short-rclpy-message-converter \ + ros-$ros_version_short-diagnostic-updater \ + ros-$ros_version_short-joint-state-publisher \ ros-$ros_version_short-rosbag2-storage-mcap \ ros-$ros_version_short-perception \ ros-$ros_version_short-cv-bridge \ ros-$ros_version_short-pcl-ros \ ros-$ros_version_short-pcl-conversions \ + ros-$ros_version_short-point-cloud-transport \ ros-$ros_version_short-visualization-msgs \ ros-$ros_version_short-sensor-msgs \ ros-$ros_version_short-geometry-msgs \ - libpcl-dev \ + ros-$ros_version_short-mavros-msgs \ + ros-$ros_version_short-nmea-msgs \ + ros-$ros_version_short-geographic-msgs \ + ros-$ros_version_short-vision-msgs \ + ros-$ros_version_short-v4l2-camera \ + libpcl-dev && \ apt-get clean && rm -rf /var/lib/apt/lists/* RUN pip install --no-cache-dir --break-system-packages --upgrade pip || pip install --no-cache-dir --upgrade pip && \ From f5a1960304f65934e4f9b969000621d8294f8977 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 16:41:56 +0200 Subject: [PATCH 04/16] Add new template file for python packages, 'python.txt'. Add a new template that fixes humble autocomplete issues with zsh, --- .../assets/dockerfile_templates/python.txt | 3 ++ .../ros2_autocomplete_fix.txt | 4 +++ turludock/generate_dockerfile.py | 4 +++ turludock/generate_non_templated_files.py | 33 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 turludock/assets/dockerfile_templates/python.txt create mode 100755 turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt diff --git a/turludock/assets/dockerfile_templates/python.txt b/turludock/assets/dockerfile_templates/python.txt new file mode 100644 index 0000000..33e45a7 --- /dev/null +++ b/turludock/assets/dockerfile_templates/python.txt @@ -0,0 +1,3 @@ +# Install Python and Python related packages +RUN apt-get update && apt-get install -y python3 python3-venv python3-pip && \ + apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt b/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt new file mode 100755 index 0000000..71dab4f --- /dev/null +++ b/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt @@ -0,0 +1,4 @@ +# Fix for argcomplete for ros2 & colcon (https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107) +RUN echo "\n# Fix for argcomplete for ros2 & colcon (https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107)" >> /root/.zshrc && \ + echo 'eval "$(/usr/bin/register-python-argcomplete3 ros2)"' >> /root/.zshrc && \ + echo 'eval "$(/usr/bin/register-python-argcomplete3 colcon)"' >> /root/.zshrc \ No newline at end of file diff --git a/turludock/generate_dockerfile.py b/turludock/generate_dockerfile.py index 3bf6b9e..e526b76 100644 --- a/turludock/generate_dockerfile.py +++ b/turludock/generate_dockerfile.py @@ -14,6 +14,8 @@ generate_meld, generate_mesa, generate_ohmyzsh, + generate_python, + generate_ros_autocomplete_fix, generate_terminator, generate_vscode, ) @@ -164,6 +166,7 @@ def generate_dockerfile(yaml_config: Dict[str, Any]) -> str: # Common configuration for all images dockerfile += generate_common_env_config() dockerfile += generate_install_common_packages() + dockerfile += generate_python() dockerfile += generate_locale() dockerfile += generate_cmake(_get_package_version(yaml_config, "cmake")) dockerfile += generate_terminator() @@ -210,6 +213,7 @@ def generate_dockerfile(yaml_config: Dict[str, Any]) -> str: # Add ROS dockerfile += generate_ros(yaml_config["ros_version"]) dockerfile += generate_ros_extra(yaml_config["ros_version"]) + dockerfile += generate_ros_autocomplete_fix(yaml_config["ros_version"]) # Add the extra-packages extra_packages_label_list = list() diff --git a/turludock/generate_non_templated_files.py b/turludock/generate_non_templated_files.py index 118c2a9..10e6a8b 100644 --- a/turludock/generate_non_templated_files.py +++ b/turludock/generate_non_templated_files.py @@ -55,6 +55,15 @@ def generate_install_common_packages() -> str: return get_non_templated_file("install_common_packages.txt") +def generate_python() -> str: + """Get python.txt as a string + + Returns: + str: The python.txt as a string + """ + return get_non_templated_file("python.txt") + + def generate_locale() -> str: """Get locale.txt as a string @@ -82,6 +91,30 @@ def generate_terminator() -> str: return get_non_templated_file("terminator.txt") +def generate_ros_autocomplete_fix(ros_version_codename: str) -> str: + """Get the 'ros2_autocomplete_fix.txt' as a string + + This file is responsible for introducing a fix for zsh autocomplete. Only for "Humble". + https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107 + + Args: + ros_version_codename (str): The ROS version as codename. + + Returns: + str: The populated 'ros2_autocomplete_fix.txt' file as a string. + """ + # Only apply for Humble + if ros_version_codename == "humble": + file = "ros2_autocomplete_fix.txt" + logger.debug("Populate '{file}'") + with importlib.resources.open_text("turludock.assets.dockerfile_templates", file) as f: + str_output = f.read() + str_output += "\n\n" + return str_output + else: + return "" + + def generate_conan() -> str: """Get conan.txt as a string From b4707bd02c139eff698eaaa53e6b4b26e030c831 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 16:43:04 +0200 Subject: [PATCH 05/16] Remove python installation from conan.txt as python now is installed by default anyway --- turludock/assets/dockerfile_templates/conan.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/turludock/assets/dockerfile_templates/conan.txt b/turludock/assets/dockerfile_templates/conan.txt index e528682..91c7375 100644 --- a/turludock/assets/dockerfile_templates/conan.txt +++ b/turludock/assets/dockerfile_templates/conan.txt @@ -1,7 +1,4 @@ # Install conan -RUN apt-get update && apt-get install -y python3-pip && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - RUN pip install --no-cache-dir --break-system-packages --upgrade pip || pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --break-system-packages --ignore-installed PyYAML && \ pip install --no-cache-dir --break-system-packages conan \ No newline at end of file From 24390abcaef8d8ed5afea31c127dc5f45e13bad8 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 17:07:36 +0200 Subject: [PATCH 06/16] Add plugins, zsh-autosuggestions, zsh-completions and zsh-syntax-highlighting, for oh-my-zsh --- turludock/assets/dockerfile_templates/oh_my_zsh.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/turludock/assets/dockerfile_templates/oh_my_zsh.txt b/turludock/assets/dockerfile_templates/oh_my_zsh.txt index f201750..40f0e28 100644 --- a/turludock/assets/dockerfile_templates/oh_my_zsh.txt +++ b/turludock/assets/dockerfile_templates/oh_my_zsh.txt @@ -5,5 +5,9 @@ RUN apt-get update && apt-get install -y zsh && apt-get clean && rm -rf /var/lib git clone https://github.com/sindresorhus/pure /root/.oh-my-zsh/custom/pure && \ ln -s /root/.oh-my-zsh/custom/pure/pure.zsh-theme /root/.oh-my-zsh/custom/ && \ ln -s /root/.oh-my-zsh/custom/pure/async.zsh /root/.oh-my-zsh/custom/ && \ + git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && \ + git clone https://github.com/zsh-users/zsh-completions.git ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions && \ + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && \ sed -i -e 's/robbyrussell/refined/g' /root/.zshrc && \ - sed -i '/plugins=(/c\plugins=(git pyenv)' /root/.zshrc \ No newline at end of file + sed -i '/plugins=(/c\plugins=(git pyenv zsh-autosuggestions zsh-syntax-highlighting)' /root/.zshrc && \ + sed -i '/source \$ZSH\/oh-my-zsh\.sh/i # needed for zsh-completions\nfpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src\nautoload -U compinit \&\& compinit\n' ~/.zshrc \ No newline at end of file From 862bb04d87487b9386cfe63c0a41f280489b1805 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 17:23:52 +0200 Subject: [PATCH 07/16] Add python3-dev to python.txt --- turludock/assets/dockerfile_templates/python.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turludock/assets/dockerfile_templates/python.txt b/turludock/assets/dockerfile_templates/python.txt index 33e45a7..4dffcfb 100644 --- a/turludock/assets/dockerfile_templates/python.txt +++ b/turludock/assets/dockerfile_templates/python.txt @@ -1,3 +1,3 @@ # Install Python and Python related packages -RUN apt-get update && apt-get install -y python3 python3-venv python3-pip && \ +RUN apt-get update && apt-get install -y python3 python3-dev python3-venv python3-pip && \ apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file From 180521fe0df70fbb8b570da8bbdf038763c6ab84 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Fri, 9 May 2025 17:26:18 +0200 Subject: [PATCH 08/16] Add git-lfs to install_common_packages.txt --- .../assets/dockerfile_templates/install_common_packages.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/turludock/assets/dockerfile_templates/install_common_packages.txt b/turludock/assets/dockerfile_templates/install_common_packages.txt index fbf134c..dd4aa70 100644 --- a/turludock/assets/dockerfile_templates/install_common_packages.txt +++ b/turludock/assets/dockerfile_templates/install_common_packages.txt @@ -4,6 +4,7 @@ sudo \ locales \ lsb-release \ git \ +git-lfs \ subversion \ nano \ vim \ From 55aa45c9147d5546f8158e2c3efcfcdcc2f5d915 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 00:02:21 +0200 Subject: [PATCH 09/16] Remove rosbags from ros2_extra.txt --- turludock/assets/dockerfile_templates/ros2_extra.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/turludock/assets/dockerfile_templates/ros2_extra.txt b/turludock/assets/dockerfile_templates/ros2_extra.txt index c25937c..26c8dab 100755 --- a/turludock/assets/dockerfile_templates/ros2_extra.txt +++ b/turludock/assets/dockerfile_templates/ros2_extra.txt @@ -18,7 +18,4 @@ RUN apt-get update && apt-get install -y \ ros-$ros_version_short-vision-msgs \ ros-$ros_version_short-v4l2-camera \ libpcl-dev && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN pip install --no-cache-dir --break-system-packages --upgrade pip || pip install --no-cache-dir --upgrade pip && \ - pip install rosbags \ No newline at end of file + apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file From 40ae542ce803ba7a83b728617e2443927068401d Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 00:06:49 +0200 Subject: [PATCH 10/16] Change ros2_autocomplete_fix.txt to template file to support all ROS2 distros. Adapt python functions. --- .../ros2_autocomplete_fix.txt | 4 +- turludock/generate_dockerfile.py | 2 +- turludock/generate_non_templated_files.py | 24 --------- turludock/generate_templated_files.py | 50 +++++++++++++++++-- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt b/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt index 71dab4f..646f60e 100755 --- a/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt +++ b/turludock/assets/dockerfile_templates/ros2_autocomplete_fix.txt @@ -1,4 +1,4 @@ # Fix for argcomplete for ros2 & colcon (https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107) RUN echo "\n# Fix for argcomplete for ros2 & colcon (https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107)" >> /root/.zshrc && \ - echo 'eval "$(/usr/bin/register-python-argcomplete3 ros2)"' >> /root/.zshrc && \ - echo 'eval "$(/usr/bin/register-python-argcomplete3 colcon)"' >> /root/.zshrc \ No newline at end of file + echo 'eval "$$(/usr/bin/register-$python_argcomplete ros2)"' >> /root/.zshrc && \ + echo 'eval "$$(/usr/bin/register-$python_argcomplete colcon)"' >> /root/.zshrc \ No newline at end of file diff --git a/turludock/generate_dockerfile.py b/turludock/generate_dockerfile.py index e526b76..8c0a98a 100644 --- a/turludock/generate_dockerfile.py +++ b/turludock/generate_dockerfile.py @@ -15,7 +15,6 @@ generate_mesa, generate_ohmyzsh, generate_python, - generate_ros_autocomplete_fix, generate_terminator, generate_vscode, ) @@ -34,6 +33,7 @@ generate_llvm, generate_ros, generate_ros_extra, + generate_ros_autocomplete_fix, generate_tmux, ) from turludock.helper_functions import ( diff --git a/turludock/generate_non_templated_files.py b/turludock/generate_non_templated_files.py index 10e6a8b..4077862 100644 --- a/turludock/generate_non_templated_files.py +++ b/turludock/generate_non_templated_files.py @@ -91,30 +91,6 @@ def generate_terminator() -> str: return get_non_templated_file("terminator.txt") -def generate_ros_autocomplete_fix(ros_version_codename: str) -> str: - """Get the 'ros2_autocomplete_fix.txt' as a string - - This file is responsible for introducing a fix for zsh autocomplete. Only for "Humble". - https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107 - - Args: - ros_version_codename (str): The ROS version as codename. - - Returns: - str: The populated 'ros2_autocomplete_fix.txt' file as a string. - """ - # Only apply for Humble - if ros_version_codename == "humble": - file = "ros2_autocomplete_fix.txt" - logger.debug("Populate '{file}'") - with importlib.resources.open_text("turludock.assets.dockerfile_templates", file) as f: - str_output = f.read() - str_output += "\n\n" - return str_output - else: - return "" - - def generate_conan() -> str: """Get conan.txt as a string diff --git a/turludock/generate_templated_files.py b/turludock/generate_templated_files.py index a63132e..8659579 100644 --- a/turludock/generate_templated_files.py +++ b/turludock/generate_templated_files.py @@ -28,11 +28,18 @@ def populate_templated_file(mapping: Dict[str, str], templated_file: str) -> str Returns: str: The populated templated file. """ - with importlib.resources.open_text("turludock.assets.dockerfile_templates", templated_file) as f: - src = Template(f.read()) - str_output = src.substitute(mapping) - str_output += "\n\n" - return str_output + try: + with importlib.resources.open_text("turludock.assets.dockerfile_templates", templated_file) as f: + src = Template(f.read()) + str_output = src.substitute(mapping) + str_output += "\n\n" + return str_output + except FileNotFoundError: + print(f"Template file '{templated_file}' not found.") + except KeyError as e: + print(f"Missing substitution key: {e}") + except Exception as e: + print(f"An unexpected error occurred at function `populate_templated_file`: {e}") def _get_ubuntu_base_image(version: str, nvidia: bool) -> str: @@ -245,6 +252,39 @@ def generate_ros_extra(ros_version_codename: str) -> str: # Populate the templated file return populate_templated_file(mapping, template_file) +def generate_ros_autocomplete_fix(ros_version_codename: str) -> str: + """Generates the 'ros2_autocomplete_fix.txt' templated file as string + + This file is responsible for introducing a fix for zsh autocomplete. + https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107 + + Args: + ros_version_codename (str): The ROS version as codename. + + Returns: + str: The populated 'ros2_autocomplete_fix.txt' file as a string. + + Raises: + ValueError: If ROS version not supported / not yet added by this function + """ + + if get_ros_major_version(ros_version_codename) == 1: + return "" + + template_file = "ros2_autocomplete_fix.txt" + + # Only apply for Humble + if ros_version_codename == "humble" or ros_version_codename == "iron": + mapping = {"python_argcomplete": 'python-argcomplete3'} + elif ros_version_codename == "jazzy": + mapping = {"python_argcomplete": 'python-argcomplete'} + else: + raise ValueError(f"ROS version {ros_version_codename} not yet supported by this function. " + "Ask the developer to add support!") + + logger.debug(f"Generate '{template_file}'. Input: {ros_version_codename}") + return populate_templated_file(mapping, template_file) + def generate_extra_packages_label(extra_packages_list: List[str]) -> str: """Generates the 'extra_packages_label.txt' templated file From 1c54c1c55aa18ffc556e3911984583d5cc5cb71c Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 00:07:03 +0200 Subject: [PATCH 11/16] Change cpplint.txt to only install cpplint --- turludock/assets/dockerfile_templates/cpplint.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/turludock/assets/dockerfile_templates/cpplint.txt b/turludock/assets/dockerfile_templates/cpplint.txt index f3a1020..a10ebc8 100644 --- a/turludock/assets/dockerfile_templates/cpplint.txt +++ b/turludock/assets/dockerfile_templates/cpplint.txt @@ -1,6 +1,2 @@ # Install cpplint -RUN apt-get update && apt-get install -y python3-pip && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -RUN pip install --user --no-cache-dir --break-system-packages --upgrade pip && \ - pip install --user --no-cache-dir --break-system-packages cpplint \ No newline at end of file +RUN pip install --user --no-cache-dir --break-system-packages cpplint \ No newline at end of file From cf62c7ed1cccdb252c91a1e87ec4009291266a50 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 00:07:14 +0200 Subject: [PATCH 12/16] Fix conan installation --- turludock/assets/dockerfile_templates/conan.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/turludock/assets/dockerfile_templates/conan.txt b/turludock/assets/dockerfile_templates/conan.txt index 91c7375..9368446 100644 --- a/turludock/assets/dockerfile_templates/conan.txt +++ b/turludock/assets/dockerfile_templates/conan.txt @@ -1,4 +1,4 @@ # Install conan -RUN pip install --no-cache-dir --break-system-packages --upgrade pip || pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir --break-system-packages --ignore-installed PyYAML && \ +RUN pip install --no-cache-dir --break-system-packages --ignore-installed PyYAML && \ + pip install --no-cache-dir --break-system-packages --ignore-installed distro && \ pip install --no-cache-dir --break-system-packages conan \ No newline at end of file From 58e98eb2b14f265cad1ba2662748ff1fa205f08f Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 00:07:22 +0200 Subject: [PATCH 13/16] Change python.txt to now also upgrade pip --- turludock/assets/dockerfile_templates/python.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/turludock/assets/dockerfile_templates/python.txt b/turludock/assets/dockerfile_templates/python.txt index 4dffcfb..e532257 100644 --- a/turludock/assets/dockerfile_templates/python.txt +++ b/turludock/assets/dockerfile_templates/python.txt @@ -1,3 +1,5 @@ # Install Python and Python related packages RUN apt-get update && apt-get install -y python3 python3-dev python3-venv python3-pip && \ - apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file + apt-get clean && rm -rf /var/lib/apt/lists/* +# Upgrade pip - but not all pip versions support "--break-system-packages" +RUN python3 -m pip install --upgrade pip --break-system-packages --ignore-installed || python3 -m pip install --upgrade pip \ No newline at end of file From 684f0a78219a341d7b8e8e9b1235267d9c636d0b Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 08:26:21 +0200 Subject: [PATCH 14/16] Add function comments to generate_ros_autocomplete_fix --- turludock/generate_templated_files.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/turludock/generate_templated_files.py b/turludock/generate_templated_files.py index 8659579..5a086a5 100644 --- a/turludock/generate_templated_files.py +++ b/turludock/generate_templated_files.py @@ -258,6 +258,9 @@ def generate_ros_autocomplete_fix(ros_version_codename: str) -> str: This file is responsible for introducing a fix for zsh autocomplete. https://github.com/ros2/ros2cli/issues/534#issuecomment-957516107 + This has the hidden assumption that a ROS2 version is always coupled to a Ubuntu version. + The fix should actually be on the Ubuntu version and not the ROS2 version. + Args: ros_version_codename (str): The ROS version as codename. From ea706db4474fc2de334285ddd66b5c2df746b5dd Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 08:27:04 +0200 Subject: [PATCH 15/16] Bump version to 3.2.0 --- CHANGELOG | 17 +++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5918f7b..7618708 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.0] - 2025-05-09 + +### Added +- Added new `dockerfile_templates/python.txt` template where all python related packages are defined. Now python is istalled by default +- Added new oh-my-zsh plugins: zsh-autosuggestions, zsh-completions and zsh-syntax-highlighting +- Added `git-lfs` to `dockerfile_templates/install_common_packages.txt` + +### Fixed +- Fixed `zsh` autocompletion issue in ROS2 + +### Changed +- Introduced `dockerfile_templates/ros2_extra.txt` to explicitly define extra ROS packages and reduced scope of ros2.txt + +### Removed +- Removed python installation from `dockerfile_templates/conan.txt` as python is installed by default now +- Removed any pip upgrades from template files as pip is being upgraded by default at `dockerfile_templates/python.txt` + ## [3.1.1] - 2025-03-21 ### Fixed diff --git a/pyproject.toml b/pyproject.toml index cfb53f1..d372cc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "turludock" -version = "3.1.1" +version = "3.2.0" description = "Builds ROS docker images that support GUI with either X11 or Wayland." authors = [ "Athanasios ", From 1673c666ec034e55720d92433aeb1be9e7c57dc5 Mon Sep 17 00:00:00 2001 From: Athanasios Tasoglou Date: Mon, 12 May 2025 08:29:28 +0200 Subject: [PATCH 16/16] Fix formatting --- turludock/generate_dockerfile.py | 2 +- turludock/generate_templated_files.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/turludock/generate_dockerfile.py b/turludock/generate_dockerfile.py index 8c0a98a..fa77f96 100644 --- a/turludock/generate_dockerfile.py +++ b/turludock/generate_dockerfile.py @@ -32,8 +32,8 @@ generate_header_info, generate_llvm, generate_ros, - generate_ros_extra, generate_ros_autocomplete_fix, + generate_ros_extra, generate_tmux, ) from turludock.helper_functions import ( diff --git a/turludock/generate_templated_files.py b/turludock/generate_templated_files.py index 5a086a5..b7ddf9e 100644 --- a/turludock/generate_templated_files.py +++ b/turludock/generate_templated_files.py @@ -252,6 +252,7 @@ def generate_ros_extra(ros_version_codename: str) -> str: # Populate the templated file return populate_templated_file(mapping, template_file) + def generate_ros_autocomplete_fix(ros_version_codename: str) -> str: """Generates the 'ros2_autocomplete_fix.txt' templated file as string @@ -278,13 +279,15 @@ def generate_ros_autocomplete_fix(ros_version_codename: str) -> str: # Only apply for Humble if ros_version_codename == "humble" or ros_version_codename == "iron": - mapping = {"python_argcomplete": 'python-argcomplete3'} + mapping = {"python_argcomplete": "python-argcomplete3"} elif ros_version_codename == "jazzy": - mapping = {"python_argcomplete": 'python-argcomplete'} + mapping = {"python_argcomplete": "python-argcomplete"} else: - raise ValueError(f"ROS version {ros_version_codename} not yet supported by this function. " - "Ask the developer to add support!") - + raise ValueError( + f"ROS version {ros_version_codename} not yet supported by this function. " + "Ask the developer to add support!" + ) + logger.debug(f"Generate '{template_file}'. Input: {ros_version_codename}") return populate_templated_file(mapping, template_file)