mirror of https://github.com/databricks/cli.git
add GetExecutable(); don't use DetectExecutable() in whl/infer
This commit is contained in:
parent
640de90ba2
commit
2b89625728
|
@ -16,12 +16,6 @@ type infer struct {
|
|||
func (m *infer) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||
artifact := b.Config.Artifacts[m.name]
|
||||
|
||||
// TODO use python.DetectVEnvExecutable once bundle has a way to specify venv path
|
||||
py, err := python.DetectExecutable(ctx)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
// Note: using --build-number (build tag) flag does not help with re-installing
|
||||
// libraries on all-purpose clusters. The reason is that `pip` ignoring build tag
|
||||
// when upgrading the library and only look at wheel version.
|
||||
|
@ -36,7 +30,9 @@ func (m *infer) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
|||
// version=datetime.datetime.utcnow().strftime("%Y%m%d.%H%M%S"),
|
||||
// ...
|
||||
//)
|
||||
artifact.BuildCommand = fmt.Sprintf(`"%s" setup.py bdist_wheel`, py)
|
||||
|
||||
py := python.GetExecutable()
|
||||
artifact.BuildCommand = fmt.Sprintf(`%s setup.py bdist_wheel`, py)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -11,6 +11,21 @@ import (
|
|||
"runtime"
|
||||
)
|
||||
|
||||
// GetExecutable gets appropriate python binary name for the platform
|
||||
func GetExecutable() string {
|
||||
// On Windows when virtualenv is created, the <env>/Scripts directory
|
||||
// contains python.exe but no python3.exe. However, system python does have python3 entry
|
||||
// and it is also added to PATH, so it is found first.
|
||||
|
||||
// Most installers (e.g. the ones from python.org) only install python.exe and not python3.exe
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
return "python"
|
||||
} else {
|
||||
return "python3"
|
||||
}
|
||||
}
|
||||
|
||||
// DetectExecutable looks up the path to the python3 executable from the PATH
|
||||
// environment variable.
|
||||
//
|
||||
|
@ -26,20 +41,7 @@ func DetectExecutable(ctx context.Context) (string, error) {
|
|||
//
|
||||
// See https://github.com/pyenv/pyenv#understanding-python-version-selection
|
||||
|
||||
// On Windows when virtualenv is created, the <env>/Scripts directory
|
||||
// contains python.exe but no python3.exe. However, system python does have python3 entry
|
||||
// and it is also added to PATH, so it is found first.
|
||||
if runtime.GOOS == "windows" {
|
||||
out, err := exec.LookPath("python")
|
||||
if err == nil && out != "" {
|
||||
return out, nil
|
||||
}
|
||||
if err != nil && !errors.Is(err, exec.ErrNotFound) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
out, err := exec.LookPath("python3")
|
||||
out, err := exec.LookPath(GetExecutable())
|
||||
|
||||
// most of the OS'es have python3 in $PATH, but for those which don't,
|
||||
// we perform the latest version lookup
|
||||
|
|
Loading…
Reference in New Issue