From 972aeec26522ab5227ccab57ad34dace44da1428 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 11 Feb 2020 18:55:28 +0100 Subject: [PATCH] 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. --- tools/windows/tool_setup/idf_setup.iss.inc | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/tools/windows/tool_setup/idf_setup.iss.inc b/tools/windows/tool_setup/idf_setup.iss.inc index 8699930ba5..7ae7cc1f23 100644 --- a/tools/windows/tool_setup/idf_setup.iss.inc +++ b/tools/windows/tool_setup/idf_setup.iss.inc @@ -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);