From 685deb8f0ccbaa10acc0be55301d25be8ddf9757 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Sat, 4 May 2024 10:11:47 -0700 Subject: [PATCH] adapt pip install option based on system and distro. Signed-off-by: Tomoya Fujita --- docker/Dockerfile | 10 +++++++++- scripts/github_workflows.sh | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 46669ea..4a03a82 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -36,7 +36,15 @@ RUN apt-get update \ pip curl\ --no-install-recommends \ && rm -rf /var/lib/apt/lists/* -RUN pip install openai + +# Adapt pip install option based on distro (technically ubuntu version) +RUN if [ "$ROS_DISTRO" = "humble" ]; then \ + pip install openai; \ + elif [ "$ROS_DISTRO" = "iron" ]; then \ + pip install openai; \ + else \ + pip install openai --break-system-packages; \ + fi # Build and source colcon workspace RUN cd $COLCON_WS \ diff --git a/scripts/github_workflows.sh b/scripts/github_workflows.sh index f9afc4c..e633ca1 100755 --- a/scripts/github_workflows.sh +++ b/scripts/github_workflows.sh @@ -27,13 +27,23 @@ function exit_trap() { fi } +function get_ubuntu_version () { + trap exit_trap ERR + echo "[${FUNCNAME[0]}]: get ubuntu version." + UBUNTU_VERSION=$(grep '^VERSION_ID=' /etc/os-release | awk -F'=' '{print $2}' | tr -d '"') +} + function install_prerequisites () { trap exit_trap ERR echo "[${FUNCNAME[0]}]: update and install dependent packages." apt update && apt upgrade -y # TODO@fujitatomoya: should install openai via package.xml apt install -y pip - pip install openai --break-system-packages + if [ $UBUNTU_VERSION == "24.04" ]; then + pip install openai --break-system-packages + else + pip install openai + fi #apt install -y ros-${ROS_DISTRO}-desktop --no-install-recommends cd $there } @@ -61,6 +71,7 @@ function build_colcon_package () { export DEBIAN_FRONTEND=noninteractive export COLCON_WORKSPACE=/tmp/colcon_ws +export UBUNTU_VERSION=24.04 # mark the working space root directory, so that we can come back anytime with `cd $there` mark there @@ -69,6 +80,7 @@ mark there trap exit_trap ERR # call install functions in sequence +get_ubuntu_version install_prerequisites setup_build_colcon_env build_colcon_package