Skip to content

Commit c2b2e1e

Browse files
authored
Merge pull request #8 from RouL/mise-python
[CHANGE] New feature mise-python
2 parents f04cf85 + 35dfcb4 commit c2b2e1e

File tree

10 files changed

+146
-2
lines changed

10 files changed

+146
-2
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- bitwarden-cli
1818
- bitwarden-secrets-manager
1919
- mise
20+
- mise-python
2021
- vault
2122
baseImage:
2223
- debian:latest
@@ -62,6 +63,7 @@ jobs:
6263
- bitwarden-secrets-manager
6364
- kamal
6465
- mise
66+
- mise-python
6567
- vault
6668
steps:
6769
- uses: actions/checkout@v4

bin/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ elif [[ $1 == +([0-9]) ]]; then
2727
fi
2828

2929
FEATURE="$1"
30-
BASE_IMAGE="${BASE_IMAGE:-$(echo $BASE_IMAGES | jq --raw-output ".$FEATURE // empty")}"
30+
BASE_IMAGE="${BASE_IMAGE:-$(echo $BASE_IMAGES | jq --raw-output ".\"$FEATURE\" // empty")}"
3131
BASE_IMAGE="${BASE_IMAGE:-$BASE_IMAGE_DEFAULT}"
3232

3333
cd $BASE_PATH

bin/test_autogenerated

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ elif [[ $1 == +([0-9]) ]]; then
2727
fi
2828

2929
FEATURE="$1"
30-
BASE_IMAGE="${BASE_IMAGE:-$(echo $BASE_IMAGES | jq --raw-output ".$FEATURE // empty")}"
30+
BASE_IMAGE="${BASE_IMAGE:-$(echo $BASE_IMAGES | jq --raw-output ".\"$FEATURE\" // empty")}"
3131
BASE_IMAGE="${BASE_IMAGE:-$BASE_IMAGE_DEFAULT}"
3232

3333
cd $BASE_PATH

src/mise-python/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
# mise-en-place version manager (mise)
3+
4+
Installs mise-en-place version manager.
5+
6+
## Example Usage
7+
8+
```json
9+
"features": {
10+
"ghcr.io/RouL/devcontainer-features/mise:1": {}
11+
}
12+
```
13+
14+
## Options
15+
16+
| Options Id | Description | Type | Default Value |
17+
|-----|-----|-----|-----|
18+
| no_ruby_dependencies | If set to true, the dependencies for building ruby won't be installed. | boolean | false |
19+
| no_python_dependencies | If set to true, the dependencies for building python won't be installed. | boolean | false |
20+
21+
22+
23+
---
24+
25+
_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/RouL/devcontainer-features/blob/main/src/mise/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"id": "mise",
3+
"version": "1.0.0",
4+
"name": "mise-en-place version manager",
5+
"description": "Installs mise-en-place version manager.",
6+
"dependsOn": {
7+
"ghcr.io/RouL/devcontainer-features/mise:latest": {}
8+
},
9+
"options": {
10+
"version": {
11+
"description": "Version to be installed as default.",
12+
"type": "string",
13+
"default": "latest"
14+
},
15+
"extra_versions": {
16+
"description": "Additional versions to be installed. (space separated)",
17+
"type": "string",
18+
"default": ""
19+
}
20+
}
21+
}

src/mise-python/install.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/bash
2+
set -e
3+
4+
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
5+
VERSION="${VERSION:-latest}"
6+
7+
REQUIRED_PACKAGES="build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl git libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev"
8+
9+
apt_get_update()
10+
{
11+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
12+
echo "Running apt-get update..."
13+
apt-get update -y
14+
fi
15+
}
16+
17+
check_packages() {
18+
if ! dpkg -s "$@" > /dev/null 2>&1; then
19+
apt_get_update
20+
apt-get -y install --no-install-recommends "$@"
21+
fi
22+
}
23+
24+
export DEBIAN_FRONTEND=noninteractive
25+
26+
check_packages $REQUIRED_PACKAGES
27+
28+
install() {
29+
su ${USERNAME} -c "mise use --global python@${VERSION}"
30+
}
31+
32+
echo "(*) Installing Python (${VERSION}) via mise as default..."
33+
34+
install
35+
36+
for extraVersion in $EXTRA_VERSIONS
37+
do
38+
echo "(*) Installung Python (${extraVersion}) via mise"
39+
su ${USERNAME} -c "mise install python@${VERSION}"
40+
done
41+
42+
# Clean up
43+
rm -rf /var/lib/apt/lists/*
44+
45+
echo "Done!"

test/mise-python/python3.12.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "check default python == 3.12" bash -c "python --version | grep -E '^Python 3\\.12\\.'"
7+
8+
reportResults
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source dev-container-features-test-lib
5+
6+
check "check default python == 3.13" bash -c "python --version | grep -E '^Python 3\\.13\\.'"
7+
check "check [email protected]" bash -c "mise exec [email protected] -- python --version | grep -E '^Python 3\\.12\\.'"
8+
check "check [email protected]" bash -c "mise exec [email protected] -- python --version | grep -E '^Python 3\\.11\\.'"
9+
10+
reportResults

test/mise-python/scenarios.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"python3.12": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"mise-python": {
6+
"version": "3.12"
7+
}
8+
}
9+
},
10+
"python3.13_python3.12_python3.11": {
11+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
12+
"features": {
13+
"mise-python": {
14+
"version": "3.13",
15+
"extra_versions": "3.12 3.11"
16+
}
17+
}
18+
}
19+
}

test/mise-python/test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e
3+
4+
sudo apt-get update -y > /dev/null
5+
sudo apt-get install -y curl jq ca-certificates > /dev/null
6+
7+
CURRENT_VERSION="$(curl -L --no-progress-meter https://api.github.com/repos/jdx/mise/releases/latest | jq --raw-output '.tag_name')"
8+
CURRENT_VERSION="${CURRENT_VERSION#v}"
9+
10+
source dev-container-features-test-lib
11+
12+
check "check default python" bash -c "python --version | grep -E '^Python '"
13+
14+
reportResults

0 commit comments

Comments
 (0)