From b628b4651b03f2d185f6ad285954c4e8457891e8 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Wed, 14 Aug 2024 11:13:51 +0100 Subject: [PATCH 1/2] libvirt: Support Ubuntu 23.04+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In newer versions of Ubuntu running `pip3 install kcli` results in the following error: ``` error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. ... ``` Solutions seem to be either use a virtual environment, install the package with apt (which isn't available for us as we need), or use pipx if installing an application, which we are. This attempts to use the logic to install with pipx, including a shell reload at the end of the script to force the PATH to be updated Signed-off-by: stevenhorsman --- src/cloud-api-adaptor/libvirt/config_libvirt.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cloud-api-adaptor/libvirt/config_libvirt.sh b/src/cloud-api-adaptor/libvirt/config_libvirt.sh index 5ad41be22..4b244c4ac 100755 --- a/src/cloud-api-adaptor/libvirt/config_libvirt.sh +++ b/src/cloud-api-adaptor/libvirt/config_libvirt.sh @@ -80,7 +80,17 @@ installKcli() { if ! command -v kcli >/dev/null; then echo "Installing kcli" kcli_version="$(./hack/yq-shim.sh '.tools.kcli' versions.yaml)" - sudo pip3 install kcli==${kcli_version} + if [ $OS_DISTRO == "ubuntu" ]; then + # Work around newer Ubuntu's python venv errors by using pipx to install kcli + sudo DEBIAN_FRONTEND=noninteractive apt-get install pipx -y + # export PATH="$PATH:$HOME/.local/bin" + pipx install kcli==${kcli_version} + pipx ensurepath + # Reload shell so that pipx install PATH is available + exec $SHELL + else + sudo pip3 install kcli==${kcli_version} + fi fi } From 35c2fd0ba1eae7009e8ec4cb0b00e8f6e20c1a40 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 10 Dec 2024 14:05:11 +0000 Subject: [PATCH 2/2] workflow: e2e_libvirt: Add kcli to PATH With pipx to install kcli, we now need `${HOME}/.local/bin` to be added to `PATH`, so that we can pick up the install, so try exporting this to $GITHUB_PATH Signed-off-by: stevenhorsman --- .github/workflows/e2e_libvirt.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/e2e_libvirt.yaml b/.github/workflows/e2e_libvirt.yaml index d903ef010..00d16c327 100644 --- a/.github/workflows/e2e_libvirt.yaml +++ b/.github/workflows/e2e_libvirt.yaml @@ -121,6 +121,8 @@ jobs: echo "container_runtime=\"${{ inputs.container_runtime }}\"" >> libvirt.properties # For debugging cat libvirt.properties + # Add the kcli install directory to PATH for later steps + echo "${HOME}/.local/bin" >> "$GITHUB_PATH" - name: Install gh cli run: |