Skip to content

Commit

Permalink
Merge pull request #56 from microsoft/45-support-for-python-and-pip
Browse files Browse the repository at this point in the history
Add support for Python keyring helper
  • Loading branch information
markphip authored May 7, 2024
2 parents 7903c2f + 0fb857f commit 2229b11
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ To use `codespaces_artifacts_helper_keyring` to set up authentication between `p
{
"features": {
"ghcr.io/microsoft/codespace-features/artifacts-helper:1": {
// TODO: Add parameter for installing package
"TODO": true
"python": true
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/artifacts-helper/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Azure Artifacts Credential Helper",
"id": "artifacts-helper",
"version": "1.0.5",
"version": "1.0.6",
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
"options": {
"nugetURIPrefixes": {
Expand Down Expand Up @@ -43,7 +43,12 @@
"type": "boolean",
"default": true,
"description": "Create alias for rush"
}
},
"python": {
"type": "boolean",
"default": false,
"description": "Install Python keyring helper for pip"
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
Expand Down
16 changes: 16 additions & 0 deletions src/artifacts-helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ALIAS_NPM="${NPMALIAS:-"true"}"
ALIAS_YARN="${YARNALIAS:-"true"}"
ALIAS_NPX="${NPXALIAS:-"true"}"
ALIAS_RUSH="${RUSHALIAS:-"true"}"
INSTALL_PIP_HELPER="${PYTHON:-"false"}"

# Source /etc/os-release to get OS info
. /etc/os-release
Expand Down Expand Up @@ -50,6 +51,8 @@ cd "$(dirname "$0")"

cp ./scripts/install-provider.sh /tmp
chmod +rx /tmp/install-provider.sh
cp ./scripts/install-python-keyring.sh /tmp
chmod +rx /tmp/install-python-keyring.sh

sed "s|REPLACE_WITH_AZURE_DEVOPS_NUGET_FEED_URL_PREFIX|${PREFIXES}|g" ./scripts/run-dotnet.sh > /usr/local/bin/run-dotnet.sh
chmod +rx /usr/local/bin/run-dotnet.sh
Expand Down Expand Up @@ -101,6 +104,15 @@ if command -v sudo >/dev/null 2>&1; then
fi
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 python3 >/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 installation not detected, keyring helper not installed."
fi
fi
exit 0
fi
fi
Expand Down Expand Up @@ -138,6 +150,10 @@ if [ "${ALIAS_RUSH}" = "true" ]; then
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush-pnpm=/usr/local/bin/run-rush-pnpm.sh' >> /etc/zsh/zshrc || true
fi

if [ "${INSTALL_PIP_HELPER}" = "true" ]; then
bash -c "/tmp/install-python-keyring.sh"
rm /tmp/install-python-keyring.sh
fi
rm /tmp/install-provider.sh

exit 0
5 changes: 5 additions & 0 deletions src/artifacts-helper/scripts/install-python-keyring.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cd /tmp
wget -qO- 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
2 changes: 1 addition & 1 deletion test/_global/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"options": "--single-branch --no-src",
"scalar": "true"
},
"artifacts-helper": {}
"artifacts-helper": {"python" : "true"}
},
"remoteEnv": {
"EXT_GIT_PAT": "dummypat"
Expand Down

0 comments on commit 2229b11

Please sign in to comment.