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
11 changes: 11 additions & 0 deletions features/src/python/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Notes

### .0 versions for old Python versions

Python <= 3.2 didn't use correct semver and therefore the .0 version was missing the .0 (eg. 3.1.0 was only released as 3.1).

Because of this, it is not possible to install an exact .0 version for those Python releases, it will take the newest patch release in that case.

Example:
* version 3.1 => would install 3.1.5
* version 3.1.0 => would unfortunately fail
14 changes: 13 additions & 1 deletion features/src/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A package which installs Python.

```json
"features": {
"ghcr.io/postfinance/devcontainer-features/python:0.1.0": {
"ghcr.io/postfinance/devcontainer-features/python:0.2.0": {
"version": "latest",
"downloadUrl": "",
"pipIndex": "",
Expand All @@ -32,3 +32,15 @@ A package which installs Python.

- `ms-python.python`
- `ms-python.vscode-pylance`

## Notes

### .0 versions for old Python versions

Python <= 3.2 didn't use correct semver and therefore the .0 version was missing the .0 (eg. 3.1.0 was only released as 3.1).

Because of this, it is not possible to install an exact .0 version for those Python releases, it will take the newest patch release in that case.

Example:
* version 3.1 => would install 3.1.5
* version 3.1.0 => would unfortunately fail
2 changes: 1 addition & 1 deletion features/src/python/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "python",
"version": "0.1.0",
"version": "0.2.0",
"name": "Python",
"description": "A package which installs Python.",
"options": {
Expand Down
4 changes: 2 additions & 2 deletions features/src/python/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// Configuration
//////////

var pythonVersionRegexp *regexp.Regexp = regexp.MustCompile(`^(?P<d1>\d+)\.(?P<d2>\d+)(?:\.(?P<d3>\d+))?(?:(?P<s4>[a-z]+)(?P<d5>\d+))?$`)
var pythonVersionRegexp *regexp.Regexp = regexp.MustCompile(`^v(?P<raw>(\d+)\.(\d+)(?:\.(\d+))?(?:([a-z]+)(\d+))?)$`)

//////////
// Main
Expand Down Expand Up @@ -110,7 +110,7 @@ func (c *pythonComponent) InstallVersion(version *gover.Version) error {
}
// Create a symlink to the installed python version
symLinkPath := "/usr/local/python/current"
targetPath := fmt.Sprintf("/usr/local/python/%s", folderName)
targetPath := fmt.Sprintf("/usr/local/python/%s", version.Raw)
if err := installer.Tools.FileSystem.CreateSymLink(targetPath, symLinkPath, false); err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions features/test/python/install-alpha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/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.15.0a1"
13 changes: 13 additions & 0 deletions features/test/python/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,18 @@
"version": "3.9.19"
}
}
},
"install-alpha": {
"build": {
"dockerfile": "Dockerfile",
"options": [
"--add-host=host.docker.internal:host-gateway"
]
},
"features": {
"./python": {
"version": "3.15.0a1"
}
}
}
}
5 changes: 3 additions & 2 deletions installer/apk.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package installer

import (
"fmt"
"strings"

"github.com/roemer/gotaskr/execr"
Expand All @@ -11,7 +12,7 @@ type apk struct{}
func (a apk) InstallDependencies(dependencies ...string) error {
args := append([]string{"add", "--no-cache"}, dependencies...)
if err := execr.Run(true, "apk", args...); err != nil {
return err
return fmt.Errorf("failed to install dependencies: %w", err)
}
return nil
}
Expand All @@ -21,7 +22,7 @@ func (a apk) InstallLocalPackage(packagePath string) error {
packagePath = "./" + packagePath
}
if err := execr.Run(true, "apk", "add", "--no-cache", packagePath); err != nil {
return err
return fmt.Errorf("failed to install local package: %w", err)
}
return nil
}
8 changes: 4 additions & 4 deletions installer/apt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ func (a apt) InstallDependencies(dependencies ...string) error {
return nil
}
if err := execr.Run(false, "apt-get", "update"); err != nil {
return err
return fmt.Errorf("failed to update apt-get: %w", err)
}
args := append([]string{"install", "-y"}, dependencies...)
if err := execr.Run(true, "apt-get", args...); err != nil {
return err
return fmt.Errorf("failed to install dependencies: %w", err)
}
a.CleanCache()
return nil
Expand All @@ -30,10 +30,10 @@ func (a apt) InstallLocalPackage(packagePath string) error {
packagePath = "./" + packagePath
}
if err := execr.Run(false, "apt-get", "update"); err != nil {
return err
return fmt.Errorf("failed to update apt-get: %w", err)
}
if err := execr.Run(true, "apt-get", "install", "-y", packagePath); err != nil {
return err
return fmt.Errorf("failed to install local package: %w", err)
}
a.CleanCache()
return nil
Expand Down
2 changes: 1 addition & 1 deletion installer/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (f *Feature) Process() error {
return err
}
// Get the max according to the reference version
versionToInstall = gover.FindMax(allVersions, referenceVersion, false)
versionToInstall = gover.FindMax(allVersions, referenceVersion, true)
}
}

Expand Down