tools: installer: use bundled idf_tools when installing IDF 3.3.1, 4.0

This is a workaround for the 'no-site-packages' bug in the version of
idf_tools.py shipped in v4.0 and v3.3.1 (see 7a18f02ac).

When installing IDF v4.0 and v3.3.1, the installer will use the
bundled version of idf_tools.py instead of the version which comes
with IDF.
This commit is contained in:
Ivan Grokhotkov 2020-02-11 18:55:28 +01:00
parent b67a7f48a9
commit 972aeec265

View file

@ -190,27 +190,52 @@ end;
{ ------------------------------ IDF Tools setup, Python environment setup ------------------------------ }
function UseBundledIDFToolsPy(Version: String) : Boolean;
begin
Result := False;
{ Use bundled copy of idf_tools.py, as the copy shipped with these IDF versions can not work due to
the --no-site-packages bug.
}
if (Version = 'v4.0') or (Version = 'v3.3.1') then
begin
Log('UseBundledIDFToolsPy: version=' + Version + ', using bundled idf_tools.py');
Result := True;
end;
end;
procedure IDFToolsSetup();
var
CmdLine: String;
IDFPath: String;
IDFToolsPyPath: String;
IDFToolsPyCmd: String;
BundledIDFToolsPyPath: String;
JSONArg: String;
begin
IDFPath := GetIDFPath('');
IDFToolsPyPath := IDFPath + '\tools\idf_tools.py';
BundledIDFToolsPyPath := ExpandConstant('{app}\idf_tools_fallback.py');
JSONArg := '';
if FileExists(IDFToolsPyPath) then
begin
Log('idf_tools.py exists in IDF directory');
IDFToolsPyCmd := PythonExecutablePath + ' ' + IDFToolsPyPath;
if UseBundledIDFToolsPy(IDFDownloadVersion) then
begin
Log('Using the bundled idf_tools.py copy');
IDFToolsPyCmd := BundledIDFToolsPyPath;
end else begin
IDFToolsPyCmd := IDFToolsPyPath;
end;
end else begin
Log('idf_tools.py does not exist in IDF directory, using a fallback version');
IDFToolsPyCmd := ExpandConstant(PythonExecutablePath
+ ' "{app}\idf_tools_fallback.py"'
+ ' --idf-path ' + IDFPath
+ ' --tools "{app}\tools_fallback.json"');
IDFToolsPyCmd := BundledIDFToolsPyPath;
JSONArg := ExpandConstant('--tools "{app}\tools_fallback.json"');
end;
{ IDFPath not quoted, as it can not contain spaces }
IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path ' + IDFPath + JSONArg;
Log('idf_tools.py command: ' + IDFToolsPyCmd);
CmdLine := IDFToolsPyCmd + ' install';
Log('Installing tools:' + CmdLine);