From 74f875cfb3f8ca2b467460805d7223c2317ad97b Mon Sep 17 00:00:00 2001 From: Mark Phippard Date: Tue, 14 May 2024 16:44:01 +0000 Subject: [PATCH] Improve Python/pip detection --- src/artifacts-helper/devcontainer-feature.json | 2 +- src/artifacts-helper/install.sh | 18 ++++-------------- .../scripts/install-python-keyring.sh | 12 +++++++++++- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/artifacts-helper/devcontainer-feature.json b/src/artifacts-helper/devcontainer-feature.json index 4f786ad..ee3bbaf 100644 --- a/src/artifacts-helper/devcontainer-feature.json +++ b/src/artifacts-helper/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Azure Artifacts Credential Helper", "id": "artifacts-helper", - "version": "1.0.6", + "version": "1.0.7", "description": "Configures Codespace to authenticate with Azure Artifact feeds", "options": { "nugetURIPrefixes": { diff --git a/src/artifacts-helper/install.sh b/src/artifacts-helper/install.sh index fd2737b..61309f0 100755 --- a/src/artifacts-helper/install.sh +++ b/src/artifacts-helper/install.sh @@ -105,13 +105,8 @@ if command -v sudo >/dev/null 2>&1; then sudo -u ${_REMOTE_USER} bash -c "/tmp/install-provider.sh ${USENET6}" rm /tmp/install-provider.sh if [ "${INSTALL_PIP_HELPER}" = "true" ]; then - # check if python is installed - if command -v pip >/dev/null 2>&1; then - sudo -u ${_REMOTE_USER} bash -c "/tmp/install-python-keyring.sh" - rm /tmp/install-python-keyring.sh - else - echo "Python pip installation not detected, keyring helper not installed." - fi + sudo -u ${_REMOTE_USER} bash -c "/tmp/install-python-keyring.sh" + rm /tmp/install-python-keyring.sh fi exit 0 fi @@ -151,13 +146,8 @@ if [ "${ALIAS_RUSH}" = "true" ]; then fi if [ "${INSTALL_PIP_HELPER}" = "true" ]; then -# check if python is installed - if command -v pip >/dev/null 2>&1; then - bash -c "/tmp/install-python-keyring.sh" - rm /tmp/install-python-keyring.sh - else - echo "Python pip installation not detected, keyring helper not installed." - fi + bash -c "/tmp/install-python-keyring.sh" + rm /tmp/install-python-keyring.sh fi rm /tmp/install-provider.sh diff --git a/src/artifacts-helper/scripts/install-python-keyring.sh b/src/artifacts-helper/scripts/install-python-keyring.sh index 9d950a5..43bb956 100755 --- a/src/artifacts-helper/scripts/install-python-keyring.sh +++ b/src/artifacts-helper/scripts/install-python-keyring.sh @@ -1,5 +1,15 @@ #!/bin/bash + cd /tmp wget https://github.com/microsoft/codespace-features/releases/download/latest/codespaces_artifacts_helper_keyring-0.1.0-py3-none-any.whl -pip install codespaces_artifacts_helper_keyring-0.1.0-py3-none-any.whl \ No newline at end of file +if command -v python3 &> /dev/null +then + python3 -m pip install codespaces_artifacts_helper_keyring-0.1.0-py3-none-any.whl +elif command -v python &> /dev/null +then + python -m pip install codespaces_artifacts_helper_keyring-0.1.0-py3-none-any.whl +else + echo "Python installation not detected. Artifacts Helper keyring not installed." + exit 1 +fi