Skip to content

Commit abbaeee

Browse files
committed
Detect free-threaded python presence.
1 parent 7b9ada2 commit abbaeee

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Source/PythonVersions.pas

+13-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TPythonVersion = record
3333
function GetDisplayName: string;
3434
function GetApiVersion: integer;
3535
function GetSysArchitecture: string;
36-
function GetPythonExecutable: string;
36+
function GetPythonExecutable(Index: Integer): string;
3737
public
3838
IsRegistered: Boolean;
3939
IsAllUsers: Boolean;
@@ -46,7 +46,8 @@ TPythonVersion = record
4646
function Is_virtualenv: Boolean;
4747
function Is_conda: Boolean;
4848
procedure AssignTo(PythonEngine: TPersistent);
49-
property PythonExecutable: string read GetPythonExecutable;
49+
property PythonExecutable: string index 0 read GetPythonExecutable;
50+
property PythonFreeThreadedExecutable: string index 1 read GetPythonExecutable;
5051
property DLLName: string read GetDLLName;
5152
property SysArchitecture: string read GetSysArchitecture;
5253
property IsPython3K: Boolean read GetIsPython3K;
@@ -204,11 +205,18 @@ function TPythonVersion.GetIsPython3K: Boolean;
204205
end;
205206
end;
206207

207-
function TPythonVersion.GetPythonExecutable: string;
208+
function TPythonVersion.GetPythonExecutable(Index: Integer): string;
209+
var
210+
ExeName: string;
208211
begin
209-
Result := IncludeTrailingPathDelimiter(InstallPath) + 'python.exe';
212+
if Index = 0 then
213+
ExeName := 'python.exe'
214+
else
215+
ExeName := Format('python%st.exe', [SysVersion]);
216+
217+
Result := IncludeTrailingPathDelimiter(InstallPath) + ExeName;
210218
if not FileExists(Result) then begin
211-
Result := IncludeTrailingPathDelimiter(InstallPath) + 'Scripts' + PathDelim + 'python.exe';
219+
Result := IncludeTrailingPathDelimiter(InstallPath) + 'Scripts' + PathDelim + ExeName;
212220
if not FileExists(Result) then Result := '';
213221
end;
214222
end;

0 commit comments

Comments
 (0)