From b67a7f48a9a0d07cd29d6e01aef18120aded9963 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 10 Feb 2020 22:04:55 +0100 Subject: [PATCH 1/5] tools: installer: fix copying IDF to a destination on another drive Closes https://github.com/espressif/esp-idf/issues/4128 Closes https://github.com/espressif/esp-idf/issues/4744 --- tools/windows/tool_setup/idf_setup.iss.inc | 26 +++++++++------------- tools/windows/tool_setup/utils.iss.inc | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/tools/windows/tool_setup/idf_setup.iss.inc b/tools/windows/tool_setup/idf_setup.iss.inc index 09d6871b52..8699930ba5 100644 --- a/tools/windows/tool_setup/idf_setup.iss.inc +++ b/tools/windows/tool_setup/idf_setup.iss.inc @@ -87,7 +87,7 @@ begin CmdLine := GitExecutablePath + ' -C ' + Path + ' submodule foreach git repack -d -a' DoCmdlineInstall('Finishing ESP-IDF installation', 'Re-packing the submodules', CmdLine); - FindFileRecusive(Path + '\.git', 'alternates', @RemoveAlternatesFile); + FindFileRecursive(Path + '\.git', 'alternates', @RemoveAlternatesFile); end; { Run git reset --hard in the repo and in the submodules, to fix the newlines. } @@ -122,7 +122,6 @@ var IDFTempPath: String; IDFPath: String; NeedToClone: Boolean; - Res: Boolean; begin IDFPath := IDFDownloadPath; @@ -168,7 +167,7 @@ begin GitRepoDissociate(IDFPath); end else begin - Log('Moving ' + IDFTempPath + ' to ' + IDFPath); + Log('Copying ' + IDFTempPath + ' to ' + IDFPath); if DirExists(IDFPath) then begin if not DirIsEmpty(IDFPath) then @@ -176,21 +175,16 @@ begin MsgBox('Destination directory exists and is not empty: ' + IDFPath, mbError, MB_OK); RaiseException('Failed to copy ESP-IDF') end; - - Res := RemoveDir(IDFPath); - if not Res then - begin - MsgBox('Failed to remove destination directory: ' + IDFPath, mbError, MB_OK); - RaiseException('Failed to copy ESP-IDF') - end; - end; - Res := RenameFile(IDFTempPath, IDFPath); - if not Res then - begin - MsgBox('Failed to copy ESP-IDF to the destination directory: ' + IDFPath, mbError, MB_OK); - RaiseException('Failed to copy ESP-IDF'); end; + { If cmd.exe command argument starts with a quote, the first and last quote chars in the command + will be removed by cmd.exe. + Keys explanation: /s+/e includes all subdirectories, /i assumes that destination is a directory, + /h copies hidden files, /q disables file name logging (making copying faster!) + } + CmdLine := ExpandConstant('cmd.exe /c ""xcopy" /s /e /i /h /q "' + IDFTempPath + '" "' + IDFPath + '""'); + DoCmdlineInstall('Extracting ESP-IDF', 'Copying ESP-IDF into the destination directory', CmdLine); GitRepoFixNewlines(IDFPath); + DelTree(IDFTempPath, True, True, True); end; end; diff --git a/tools/windows/tool_setup/utils.iss.inc b/tools/windows/tool_setup/utils.iss.inc index a93f6ad491..6e7b709f8b 100644 --- a/tools/windows/tool_setup/utils.iss.inc +++ b/tools/windows/tool_setup/utils.iss.inc @@ -92,7 +92,7 @@ end; type TFindFileCallback = procedure(Filename: String); -procedure FindFileRecusive(Directory: string; FileName: string; Callback: TFindFileCallback); +procedure FindFileRecursive(Directory: string; FileName: string; Callback: TFindFileCallback); var FindRec: TFindRec; FilePath: string; @@ -107,7 +107,7 @@ begin FilePath := Directory + '\' + FindRec.Name; if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin - FindFileRecusive(FilePath, FileName, Callback); + FindFileRecursive(FilePath, FileName, Callback); end else if CompareText(FindRec.Name, FileName) = 0 then begin Callback(FilePath); From 972aeec26522ab5227ccab57ad34dace44da1428 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 11 Feb 2020 18:55:28 +0100 Subject: [PATCH 2/5] 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); From 24e793baa3cecf33d1fbba5c61bbb7eda5197c3b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 11 Feb 2020 18:56:18 +0100 Subject: [PATCH 3/5] tools: installer: add PYTHONUNBUFFERED=1 when calling idf_tools.py Fixes the issue that there is no output from 'idf_tools.py install' stage. --- tools/windows/tool_setup/idf_setup.iss.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/windows/tool_setup/idf_setup.iss.inc b/tools/windows/tool_setup/idf_setup.iss.inc index 7ae7cc1f23..6b6e49c540 100644 --- a/tools/windows/tool_setup/idf_setup.iss.inc +++ b/tools/windows/tool_setup/idf_setup.iss.inc @@ -236,6 +236,8 @@ begin { IDFPath not quoted, as it can not contain spaces } IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path ' + IDFPath + JSONArg; + SetEnvironmentVariable('PYTHONUNBUFFERED', '1') + Log('idf_tools.py command: ' + IDFToolsPyCmd); CmdLine := IDFToolsPyCmd + ' install'; Log('Installing tools:' + CmdLine); From 69e91959ff1d252bcd90ab780073306799ae045a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 10 Feb 2020 19:34:30 +0100 Subject: [PATCH 4/5] tools: bump version of windows tools installer to v2.3 Includes the following fixes: - bc43d48e: fix Windows Defender checkbox https://github.com/espressif/esp-idf/issues/4225 - 7a18f02a: idf_tools.py compatibility with virtualenv 20.0 - Fix extracting IDF to a destination on another drive https://github.com/espressif/esp-idf/issues/4128 https://github.com/espressif/esp-idf/issues/4744 --- tools/windows/tool_setup/idf_tool_setup.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/windows/tool_setup/idf_tool_setup.iss b/tools/windows/tool_setup/idf_tool_setup.iss index 8e39f60ee9..d85c476978 100644 --- a/tools/windows/tool_setup/idf_tool_setup.iss +++ b/tools/windows/tool_setup/idf_tool_setup.iss @@ -5,7 +5,7 @@ #include #define MyAppName "ESP-IDF Tools" -#define MyAppVersion "2.2" +#define MyAppVersion "2.3" #define MyAppPublisher "Espressif Systems (Shanghai) Co. Ltd." #define MyAppURL "https://github.com/espressif/esp-idf" From 700161921c22ca66e66c3295c9e9555fa1340fef Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 10 Feb 2020 19:34:56 +0100 Subject: [PATCH 5/5] docs: update version of IDF tools installer for windows to v2.3 --- docs/en/get-started/windows-setup.rst | 2 +- docs/zh_CN/get-started/windows-setup.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/get-started/windows-setup.rst b/docs/en/get-started/windows-setup.rst index e617ddedb0..601a9a03e4 100644 --- a/docs/en/get-started/windows-setup.rst +++ b/docs/en/get-started/windows-setup.rst @@ -28,7 +28,7 @@ ESP-IDF Tools Installer The easiest way to install ESP-IDF's prerequisites is to download the ESP-IDF Tools installer from this URL: -https://dl.espressif.com/dl/esp-idf-tools-setup-2.2.exe +https://dl.espressif.com/dl/esp-idf-tools-setup-2.3.exe The installer includes the cross-compilers, OpenOCD, cmake_ and Ninja_ build tool. The installer can also download and run installers for Python_ 3.7 and `Git For Windows`_ if they are not already installed on the computer. diff --git a/docs/zh_CN/get-started/windows-setup.rst b/docs/zh_CN/get-started/windows-setup.rst index c3cb983425..ffabf8aeaa 100644 --- a/docs/zh_CN/get-started/windows-setup.rst +++ b/docs/zh_CN/get-started/windows-setup.rst @@ -28,7 +28,7 @@ ESP-IDF 工具安装器 要安装 ESP-IDF 必备工具,最简易的方式是下载 ESP-IDF 工具安装器,地址如下: -https://dl.espressif.com/dl/esp-idf-tools-setup-2.2.exe +https://dl.espressif.com/dl/esp-idf-tools-setup-2.3.exe 本安装器可为您安装所需的交叉编译器、OpenOCD、cmake_ 和 Ninja_ 编译工具,以及一款 mconf-idf_ 配置工具。此外,本安装器还可在有需要时下载、运行 Python_ 3.7 和 `Git For Windows` 的安装器。