fix(python): do not clear virtualenv in pyenv

resolves #2582
This commit is contained in:
Jan De Dobbeleer 2022-07-28 07:48:52 +02:00 committed by Jan De Dobbeleer
parent 1899896c6d
commit c22d0d67be
2 changed files with 3 additions and 4 deletions

View file

@ -135,8 +135,7 @@ func (p *Python) pyenvVersion() (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
// Unset whatever loadContext thinks Venv should be // override virtualenv if pyenv set one
p.Venv = ""
parts := strings.Split(shortPath, string(filepath.Separator)) parts := strings.Split(shortPath, string(filepath.Separator))
if len(parts) > 2 && p.canUseVenvName(parts[2]) { if len(parts) > 2 && p.canUseVenvName(parts[2]) {
p.Venv = parts[2] p.Venv = parts[2]

View file

@ -70,9 +70,9 @@ func TestPythonTemplate(t *testing.T) {
Case: "Pyenv virtual env version name", Case: "Pyenv virtual env version name",
FetchVersion: true, FetchVersion: true,
VirtualEnvName: "demo", VirtualEnvName: "demo",
Expected: "3.8.4", Expected: "demo 3.8.4",
PythonPath: "/home/user/.pyenv/shims/python", PythonPath: "/home/user/.pyenv/shims/python",
Template: "{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}", Template: "{{ .Venv }} {{ .Full }}",
ResolveSymlink: ResolveSymlink{Path: "/home/user/.pyenv/versions/demo", Err: nil}, ResolveSymlink: ResolveSymlink{Path: "/home/user/.pyenv/versions/demo", Err: nil},
}, },
} }