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
4 changes: 2 additions & 2 deletions features/src/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Installs Python.

```json
"features": {
"ghcr.io/postfinance/devcontainer-features/python:1.1.0": {
"ghcr.io/postfinance/devcontainer-features/python:1.2.0": {
"version": "latest",
"downloadUrl": "",
"pipIndex": "",
Expand All @@ -20,7 +20,7 @@ Installs Python.

| Option | Description | Type | Default Value | Proposals |
|-----|-----|-----|-----|-----|
| version | The version of Python to install. | string | latest | latest, 3.12, 3.9.19 |
| version | The version of Python to install. | string | latest | latest, system-default, 3.12, 3.9.19 |
| downloadUrl | The download URL to use. | string | <empty> | https://mycompany.com/artifactory/python-generic-ftp-remote, https://mycompany.com/artifactory/python-generic-remote/ftp/python |
| pipIndex | The pip index to use (used by search). | string | <empty> | https://mycompany.com/artifactory/api/pypi/python/simple, https://mycompany.com/nexus/repository/pypi-group/pypi |
| pipIndexUrl | The pip index URL to use (used by install). | string | <empty> | https://mycompany.com/artifactory/api/pypi/python/simple, https://mycompany.com/nexus/repository/pypi-group/simple |
Expand Down
5 changes: 3 additions & 2 deletions features/src/python/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"id": "python",
"version": "1.1.0",
"version": "1.2.0",
"name": "Python",
"description": "Installs Python.",
"options": {
"version": {
"type": "string",
"proposals": [
"latest",
"system-default",
"3.12",
"3.9.19"
],
Expand Down Expand Up @@ -67,4 +68,4 @@
"PATH": "/usr/local/python/current/bin:${PATH}",
"PYTHON_PATH": "/usr/local/python/current"
}
}
}
13 changes: 12 additions & 1 deletion features/src/python/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@ func (c *pythonComponent) GetAllVersions() ([]*gover.Version, error) {
}

func (c *pythonComponent) InstallVersion(version *gover.Version) error {
// Download the file
if version == gover.EmptyVersion {
return installer.Tools.System.InstallPackagesByOs(func(osInfo *installer.OsInfo) ([]string, error) {
if osInfo.IsDebian() || osInfo.IsUbuntu() {
return []string{"python3", "python3-pip", "python-is-python3"}, nil
} else if osInfo.IsAlpine() {
return []string{"python3", "py3-pip"}, nil
}
return nil, fmt.Errorf("unsupported OS vendor: %s", osInfo.Vendor)
})
}

// Download and compile a specific version of Python
name := fmt.Sprintf("Python-%s", version.Raw)
fileName := fmt.Sprintf("%s.tgz", name)
// The folder only contains the major, minor and sometimes the patch version
Expand Down
10 changes: 10 additions & 0 deletions features/test/python/install-system-provided.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"

check_version "$(python --version)" "Python 3."
check_command_exists python3
check_command_exists python
check_command_exists pip
10 changes: 10 additions & 0 deletions features/test/python/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@
"version": "3.15.0a1"
}
}
},
"install-system-provided": {
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"./python": {
"version": "system-default"
}
}
}
}