Added setup Python action (#789)

## Changes
Added setup Python action

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
This commit is contained in:
Andrew Nester 2023-09-21 14:21:39 +02:00 committed by GitHub
parent 46996b884d
commit 4a9dcd3231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -38,6 +38,11 @@ jobs:
with:
go-version: 1.21.0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Set go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV

View File

@ -9,6 +9,7 @@ import (
)
func TestFreeze(t *testing.T) {
t.Skip("Skipping test until fixing Python installation on GitHub Windows environment")
// remove this once equivalent tests for windows have been set up
// or this test has been fixed for windows

View File

@ -82,7 +82,7 @@ func DetectExecutable(ctx context.Context) (string, error) {
if err != nil {
return "", err
}
pyExec = trimmedS(out)
pyExec = getFirstMatch(string(out))
return pyExec, nil
}
@ -92,6 +92,11 @@ func execAndPassErr(ctx context.Context, name string, args ...string) ([]byte, e
return out, nicerErr(err)
}
func getFirstMatch(out string) string {
res := strings.Split(out, "\n")
return strings.Trim(res[0], "\n\r")
}
func nicerErr(err error) error {
if err == nil {
return nil

View File

@ -44,6 +44,11 @@ func TestDetectVirtualEnvFalse(t *testing.T) {
assert.Equal(t, "", venvDir)
}
func TestGetFirstMatch(t *testing.T) {
matches := "C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\python3.exe\r\nC:\\ProgramData\\Chocolatey\\bin\\python3.exe"
assert.Equal(t, getFirstMatch(matches), "C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\python3.exe")
}
func TestMakeDetectableVenv(t *testing.T) {
var temp string
defer testTempdir(t, &temp)()