-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(features-pixi): adding
pixi
devcontainer feature! (#36)
Signed-off-by: John Muchovej <[email protected]> Co-authored-by: John Muchovej <[email protected]>
- Loading branch information
Showing
10 changed files
with
203 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Limitations | ||
|
||
The `onCreateCommand` relies on having passwordless `sudo` access. Thus, it demands that | ||
both `sudo` is available and the `${remoteUser}` has passwordless access! | ||
|
||
## OS Support | ||
This feature has been tested on Debian-based distributions (Ubuntu & Debian). As of | ||
**14 Sep 2024**, **Alpine is unsupported**. This is because Alpine does not provide a | ||
the virtual package `__glibc`, which means that packages have `glibc` dependencies | ||
cannot be used (_many of the core `conda` packages require `glibc` in some fashion). | ||
Thus, there's little use in starting from an `alpine` image. | ||
|
||
More details on [this GitHub issue][no-alpine-install] (tracked by the folks at | ||
Prefix.dev). | ||
|
||
[no-alpine-install]: https://github.com/prefix-dev/pixi-docker/issues/23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"$schema": "https://github.com/devcontainers/spec/raw/main/schemas/devContainerFeature.schema.json", | ||
"id": "pixi", | ||
"version": "0.1.0", | ||
"name": "pixi", | ||
"documentationURL": "https://github.com/jmuchovej/devcontainers/tree/main/features/pixi", | ||
"description": "Add Pixi (by Prefix.dev) to your Dev Container!", | ||
"options": { | ||
"version": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"v0.29.0", | ||
"v0.28.0", | ||
"v0.27.0", | ||
], | ||
"default": "latest", | ||
"description": "Select (or enter) the version of pixi you want to install." | ||
}, | ||
}, | ||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/git", | ||
"ghcr.io/devcontainers/features/github-cli", | ||
"ghcr.io/devcontainers/features/common-utils" | ||
], | ||
// This mount is provided to ease developer experience, particularly on MacOS. | ||
// By default, MacOS is case-insensitive; however, Linux is [by default] case-sensitive. | ||
// Thus, when running Linux-based containers but bind-mounting `/path/to/.pixi`, any | ||
// libraries with case-sensitive filenames (e.g., `ncurses`) will fail to install. | ||
"mounts": [ | ||
{ "type": "volume", "target": "${containerWorkspaceFolder}/.pixi", "source": "${devcontainerId}-pixi", } | ||
], | ||
"onCreateCommand": { | ||
"update .pixi permissions": "sudo chown -R $(id -u) ${containerWorkspaceFolder}/.pixi", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
err 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||
exit 1 | ||
fi | ||
|
||
PIXI_HOME=/usr/local | ||
PIXI_VERSION="${VERSION:-"latest"}" | ||
[ "${PIXI_VERSION}" != "latest" ] && PIXI_VERSION="${PIXI_VERSION}" | ||
|
||
curl -fsSL https://pixi.sh/install.sh | \ | ||
PIXI_VERSION="${PIXI_VERSION}" PIXI_HOME="${PIXI_HOME}" bash | ||
|
||
if [ -f "/etc/bash.bashrc" ]; then | ||
echo <<-EOF | tee -a /etc/bash.bashrc | ||
# From: jmuchovej/features/pixi | ||
eval "$(pixi completion --shell bash)" | ||
EOF | ||
fi | ||
|
||
if [ -f "/etc/zsh/zshrc" ]; then | ||
echo <<-EOF | tee -a /etc/zsh/zshrc | ||
# From: jmuchovej/features/pixi | ||
eval "$(pixi completion --shell zsh)" | ||
EOF | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export VERSION | ||
$(dirname ${0})/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export VERSION | ||
$(dirname ${0})/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"on-ubuntu": { | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils": { | ||
"installZsh": false, | ||
"installOhMyZsh": false, | ||
"upgradePackages": false | ||
}, | ||
"pixi": { | ||
"version": "latest" | ||
} | ||
}, | ||
"remoteUser": "vscode" | ||
}, | ||
"on-debian": { | ||
"image": "mcr.microsoft.com/devcontainers/base:debian", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils": { | ||
"installZsh": false, | ||
"installOhMyZsh": false, | ||
"upgradePackages": false | ||
}, | ||
"pixi": { | ||
"version": "latest" | ||
} | ||
}, | ||
"remoteUser": "vscode" | ||
}, | ||
"with-v0.29.0": { | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils": { | ||
"installZsh": false, | ||
"installOhMyZsh": false, | ||
"upgradePackages": false | ||
}, | ||
"pixi": { | ||
"version": "v0.29.0" | ||
} | ||
}, | ||
"remoteUser": "vscode" | ||
}, | ||
"with-v0.28.0": { | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils": { | ||
"installZsh": false, | ||
"installOhMyZsh": false, | ||
"upgradePackages": false | ||
}, | ||
"pixi": { | ||
"version": "v0.28.0" | ||
} | ||
}, | ||
"remoteUser": "vscode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# This is a generic test since the primary difference in tests is across versions. | ||
set -e | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
source dev-container-features-test-lib | ||
|
||
if [ "${VERSION}" = "latest" ]; then | ||
VERSION="$(curl -s https://api.github.com/repos/prefix-dev/pixi/releases | jq -r ".[0].tag_name")" | ||
fi | ||
|
||
VERSION_CHECK="${VERSION//v}" | ||
|
||
# Feature-specific tests | ||
# The 'check' command comes from the dev-container-features-test-lib. | ||
check \ | ||
"validate pixi \`${VERSION_CHECK}\` is installed" \ | ||
bash -c "pixi --version | grep \"${VERSION_CHECK}\"" | ||
|
||
check \ | ||
"test that we can \`init\` a pixi project" \ | ||
bash -c "pixi init -p linux-aarch64 -p linux-64 -c conda-forge" | ||
|
||
check \ | ||
"can add libraries?" \ | ||
bash -c "pixi add scipy numpy pandas; pixi clean" | ||
|
||
check \ | ||
"install pixi environments" \ | ||
bash -c "pixi install -a" | ||
|
||
check \ | ||
"run pixi tasks" \ | ||
bash -c "pixi run python --version" | ||
|
||
check \ | ||
"did libraries install?" | ||
bash -c "pixi run python -c 'import pandas'" | ||
|
||
# Report result | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export VERSION | ||
$(dirname ${0})/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export VERSION | ||
$(dirname ${0})/test.sh |