2020-12-16 11:40:13 -05:00
|
|
|
{ Copyright 2019-2021 Espressif Systems (Shanghai) CO LTD
|
2019-04-28 22:36:03 -04:00
|
|
|
SPDX-License-Identifier: Apache-2.0 }
|
|
|
|
|
|
|
|
{ ------------------------------ Find installed Python interpreters in Windows Registry (see PEP 514) ------------------------------ }
|
|
|
|
|
|
|
|
var
|
|
|
|
InstalledPythonVersions: TStringList;
|
|
|
|
InstalledPythonDisplayNames: TStringList;
|
|
|
|
InstalledPythonExecutables: TStringList;
|
|
|
|
|
|
|
|
procedure PythonVersionAdd(Version, DisplayName, Executable: String);
|
|
|
|
begin
|
|
|
|
Log('Adding Python version=' + Version + ' name='+DisplayName+' executable='+Executable);
|
|
|
|
InstalledPythonVersions.Append(Version);
|
|
|
|
InstalledPythonDisplayNames.Append(DisplayName);
|
|
|
|
InstalledPythonExecutables.Append(Executable);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function GetPythonVersionInfoFromKey(RootKey: Integer; SubKeyName, CompanyName, TagName: String;
|
|
|
|
var Version: String;
|
|
|
|
var DisplayName: String;
|
2020-11-26 10:00:55 -05:00
|
|
|
var ExecutablePath: String;
|
|
|
|
var BaseDir: String): Boolean;
|
2019-04-28 22:36:03 -04:00
|
|
|
var
|
|
|
|
TagKey, InstallPathKey, DefaultPath: String;
|
|
|
|
begin
|
|
|
|
TagKey := SubKeyName + '\' + CompanyName + '\' + TagName;
|
|
|
|
InstallPathKey := TagKey + '\InstallPath';
|
|
|
|
|
|
|
|
if not RegQueryStringValue(RootKey, InstallPathKey, '', DefaultPath) then
|
|
|
|
begin
|
|
|
|
Log('No (Default) key, skipping');
|
|
|
|
Result := False;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if not RegQueryStringValue(RootKey, InstallPathKey, 'ExecutablePath', ExecutablePath) then
|
|
|
|
begin
|
|
|
|
Log('No ExecutablePath, using the default');
|
|
|
|
ExecutablePath := DefaultPath + '\python.exe';
|
|
|
|
end;
|
|
|
|
|
2020-11-26 10:00:55 -05:00
|
|
|
BaseDir := DefaultPath;
|
|
|
|
|
2019-04-28 22:36:03 -04:00
|
|
|
if not RegQueryStringValue(RootKey, TagKey, 'SysVersion', Version) then
|
|
|
|
begin
|
|
|
|
if CompanyName = 'PythonCore' then
|
|
|
|
begin
|
|
|
|
Version := TagName;
|
|
|
|
Delete(Version, 4, Length(Version));
|
|
|
|
end else begin
|
|
|
|
Log('Can not determine SysVersion');
|
|
|
|
Result := False;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if not RegQueryStringValue(RootKey, TagKey, 'DisplayName', DisplayName) then
|
|
|
|
begin
|
|
|
|
DisplayName := 'Python ' + Version;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := True;
|
|
|
|
end;
|