Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"pythonDeps": "jupyter,papermill",
"juliaDeps": "IJulia"
},
"./uv": {
"version": "latest"
},
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
"version": "prerelease",
"installTinyTex": "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ R_DEPS=${RDEPS:-"rmarkdown"}
PYTHON_DEPS=${PYTHONDEPS:-"jupyter,papermill"}
JULIA_DEPS=${JULIADEPS:-"IJulia"}

set -e

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
Expand Down
17 changes: 17 additions & 0 deletions .github/.devcontainer/uv/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "uv",
"version": "1.0.0",
"name": "uv",
"description": "Install uv, an extremely fast Python package and project manager, written in Rust.",
"options": {
"version": {
"default": "latest",
"description": "Select the version to install.",
"proposals": ["latest"],
"type": "string"
}
},
"installsAfter": [
"./quarto-computing-dependencies"
]
}
61 changes: 61 additions & 0 deletions .github/.devcontainer/uv/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash

set -e

export DEBIAN_FRONTEND=noninteractive

USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}}

VERSION=${VERSION:-"latest"}

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

# Determine the appropriate non-root user
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
USERNAME=""
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
for CURRENT_USER in "${POSSIBLE_USERS[@]}"; do
if id -u "${CURRENT_USER}" >/dev/null 2>&1; then
USERNAME=${CURRENT_USER}
break
fi
done
if [ "${USERNAME}" = "" ]; then
USERNAME=root
fi
elif [ "${USERNAME}" = "none" ] || ! id -u "${USERNAME}" >/dev/null 2>&1; then
USERNAME=root
fi

apt_get_update() {
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
}

# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}

install_uv() {
local version=$1
local url="https://github.com/astral-sh/uv/releases/${version}/download/uv-installer.sh"
check_packages curl ca-certificates
su "${USERNAME}" -c "curl --proto '=https' --tlsv1.2 -LsSf ${url} | sh"
}

enable_autocompletion() {
su "${USERNAME}" -c "echo 'eval \"\$(uv generate-shell-completion zsh)\"' >> \"\$HOME/.zshrc\""
su "${USERNAME}" -c "echo 'eval \"\$(uvx --generate-shell-completion zsh)\"' >> \"\$HOME/.zshrc\""
}

install_uv ${VERSION}
enable_autocompletion