Skip to content

Commit a29e2d4

Browse files
committed
Support VirtualEnv v20+. Drop support for earlier versions
1 parent d683ccd commit a29e2d4

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

PythonForDelphi/Components/Sources/Core/PythonVersions.pas

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ function TPythonVersion.GetDisplayName: string;
156156
FormatStr := 'Conda %s (%s)'
157157
else
158158
FormatStr := 'Python %s (%s)';
159-
if Is_venv then
160-
FormatStr := FormatStr + ' -venv'
161-
else if Is_virtualenv then
162-
FormatStr := FormatStr + ' -virtualenv';
159+
if Is_virtualenv then
160+
FormatStr := FormatStr + ' -virtualenv'
161+
else if Is_venv then
162+
FormatStr := FormatStr + ' -venv';
163163

164164
FDisplayName := Format(FormatStr, [SysVersion, SysArchitecture]);
165165
end;
@@ -197,7 +197,7 @@ function TPythonVersion.GetPythonExecutable: string;
197197
begin
198198
Result := IncludeTrailingPathDelimiter(InstallPath) + 'python.exe';
199199
if not FileExists(Result) then begin
200-
Result := IncludeTrailingPathDelimiter(InstallPath) + 'Scripts\python.exe';
200+
Result := IncludeTrailingPathDelimiter(InstallPath) + 'Scripts' + PathDelim + 'python.exe';
201201
if not FileExists(Result) then Result := '';
202202
end;
203203
end;
@@ -226,8 +226,7 @@ function TPythonVersion.Is_venv: Boolean;
226226

227227
function TPythonVersion.Is_virtualenv: Boolean;
228228
begin
229-
Result := not IsRegistered and (InstallPath <> DLLPath) and
230-
not FileExists(IncludeTrailingPathDelimiter(InstallPath) + 'pyvenv.cfg');
229+
Result := Is_venv and FileExists(IncludeTrailingPathDelimiter(InstallPath) + 'Scripts' + PathDelim + DLLName);
231230
end;
232231

233232
function CompareVersions(A, B : string) : Integer;
@@ -485,10 +484,6 @@ function PythonVersionFromPath(const Path: string; out PythonVersion: TPythonVer
485484

486485
DLLFileName := FindPythonDLL(DLLPath);
487486

488-
if (DLLFileName = '') and AcceptVirtualEnvs then begin
489-
DLLPath := DLLPath + '\Scripts';
490-
DLLFileName := FindPythonDLL(DLLPath);
491-
end;
492487
if DLLFileName = '' then begin
493488
if AcceptVirtualEnvs and PythonVersion.Is_venv then
494489
begin

0 commit comments

Comments
 (0)