diff --git a/src/config.ts b/src/config.ts index ee1fb3d6e..8c0a24117 100644 --- a/src/config.ts +++ b/src/config.ts @@ -92,6 +92,10 @@ export namespace ESP { export const VERSION = "2.39.2"; export const IDF_EMBED_GIT_URL = `https://dl.espressif.com/dl/idf-git/idf-git-${VERSION}-win64.zip`; } + export namespace OLD_IDF_EMBED_PYTHON { + export const VERSION = "3.8.7"; + export const IDF_EMBED_PYTHON_URL = `https://dl.espressif.com/dl/idf-python/idf-python-${VERSION}-embed-win64.zip`; + } export namespace IDF_EMBED_PYTHON { export const VERSION = "3.11.2"; export const IDF_EMBED_PYTHON_URL = `https://dl.espressif.com/dl/idf-python/idf-python-${VERSION}-embed-win64.zip`; diff --git a/src/idfToolsManager.ts b/src/idfToolsManager.ts index 98e33c40a..69590e10c 100644 --- a/src/idfToolsManager.ts +++ b/src/idfToolsManager.ts @@ -336,7 +336,7 @@ export class IdfToolsManager { const expectedVersions = pkgVersionsForPlatform.map((p) => p.name); let isToolVersionCorrect = expectedVersions.indexOf(versions[pkg.name]) > -1 || - versions[pkg.name] === "No command version"; + (versions[pkg.name] && versions[pkg.name] === "No command version"); const versionToUse = this.getVersionToUse(pkg); let pkgExportedPath: string = ""; let pkgVars = pkg.export_vars; diff --git a/src/setup/SetupPanel.ts b/src/setup/SetupPanel.ts index ea7dba044..9c7db549b 100644 --- a/src/setup/SetupPanel.ts +++ b/src/setup/SetupPanel.ts @@ -33,7 +33,7 @@ import { createPyReqs } from "./pyReqsInstallStep"; import { downloadIdfTools } from "./toolsDownloadStep"; import { installIdfGit, installIdfPython } from "./embedGitPy"; import { getOpenOcdRules } from "./addOpenOcdRules"; -import { checkSpacesInPath } from "../utils"; +import { checkSpacesInPath, getEspIdfFromCMake } from "../utils"; import { useIdfSetupSettings } from "./setupValidation/espIdfSetup"; import { clearPreviousIdfSetups } from "./existingIdfSetups"; @@ -264,9 +264,8 @@ export class SetupPanel { }); SetupPanel.postMessage({ command: "setEspIdfErrorStatus", - errorMsg: `ESP-IDF is installed in ${ - setupArgs.existingIdfSetups[message.selectedIdfSetup].idfPath - }`, + errorMsg: `ESP-IDF is installed in ${setupArgs.existingIdfSetups[message.selectedIdfSetup].idfPath + }`, }); this.panel.webview.postMessage({ command: "updateEspIdfToolsStatus", @@ -369,16 +368,31 @@ export class SetupPanel { let idfPythonPath = pyPath, idfGitPath = "git"; if (process.platform === "win32") { + let idfVersion = ""; + if (selectedIdfVersion.filename === "manual") { + idfVersion = await getEspIdfFromCMake(espIdfPath); + } else if (selectedIdfVersion.filename === "master") { + idfVersion = "5.1"; + } else { + const matches = selectedIdfVersion.name.split(" ")[0].match(/v(.+)/); + if (matches && matches.length) { + idfVersion = matches[1]; + } else { + idfVersion = "5.0"; + } + } const embedPaths = await this.installEmbedPyGit( toolsPath, + idfVersion, progress, cancelToken ); idfGitPath = embedPaths.idfGitPath; idfPythonPath = embedPaths.idfPythonPath; } + const pathToCheck = selectedIdfVersion.filename === "manual" ? espIdfPath : idfContainerPath; this.checkSpacesInPaths( - espIdfPath, + pathToCheck, toolsPath, idfGitPath, idfPythonPath @@ -422,7 +436,8 @@ export class SetupPanel { ); const updatedToolsInfo = toolsInfo.map((tool) => { const isToolVersionCorrect = - tool.expected.indexOf(foundVersions[tool.name]) > -1; + tool.expected.indexOf(foundVersions[tool.name]) > -1 || + (foundVersions[tool.name] && foundVersions[tool.name] === "No command version"); tool.doesToolExist = isToolVersionCorrect; if (isToolVersionCorrect) { tool.progress = "100.00%"; @@ -484,8 +499,10 @@ export class SetupPanel { let idfPythonPath = pyPath, idfGitPath = gitPath || "/usr/bin/git"; if (process.platform === "win32") { + const idfVersion = await getEspIdfFromCMake(idfPath); const embedPaths = await this.installEmbedPyGit( toolsPath, + idfVersion, progress, cancelToken ); @@ -561,6 +578,7 @@ export class SetupPanel { private async installEmbedPyGit( toolsPath: string, + idfVersion: string, progress: vscode.Progress<{ message: string; increment?: number }>, cancelToken: vscode.CancellationToken ) { @@ -571,6 +589,7 @@ export class SetupPanel { }); const idfPythonPath = await installIdfPython( toolsPath, + idfVersion, progress, cancelToken ); diff --git a/src/setup/embedGitPy.ts b/src/setup/embedGitPy.ts index 9dcf4a2cf..e020abf79 100644 --- a/src/setup/embedGitPy.ts +++ b/src/setup/embedGitPy.ts @@ -68,7 +68,7 @@ export async function installIdfGit( if (!binVersion || binVersion === "Not found") { const msg = `Using existing ${idfGitDestPath}`; OutputChannel.appendLine(msg); - Logger.info(msg) + Logger.info(msg); return resultGitPath; } } @@ -108,28 +108,33 @@ export async function installIdfGit( export async function installIdfPython( idfToolsDir: string, + idfVersion: string, progress?: Progress<{ message: string; increment?: number }>, cancelToken?: CancellationToken ) { const downloadManager = new DownloadManager(idfToolsDir); const installManager = new InstallManager(idfToolsDir); - const idfPyZipPath = join( - idfToolsDir, - "dist", - basename(ESP.URL.IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL) - ); + const pythonURLToUse = + idfVersion >= "5.0" + ? ESP.URL.IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL + : ESP.URL.OLD_IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL; + const idfPyZipPath = join(idfToolsDir, "dist", basename(pythonURLToUse)); const pkgProgress = new PackageProgress( - basename(ESP.URL.IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL), + basename(pythonURLToUse), sendIdfPythonDownloadProgress, null, sendIdfPythonDownloadDetail, null ); + const pythonVersionToUse = + idfVersion >= "5.0" + ? ESP.URL.IDF_EMBED_PYTHON.VERSION + : ESP.URL.OLD_IDF_EMBED_PYTHON.VERSION; const idfPyDestPath = join( idfToolsDir, "tools", "idf-python", - ESP.URL.IDF_EMBED_PYTHON.VERSION + pythonVersionToUse ); const pyPathExists = await pathExists(idfPyDestPath); if (pyPathExists) { @@ -148,7 +153,7 @@ export async function installIdfPython( if (!pyZipPathExists) { progress.report({ message: `Downloading ${idfPyZipPath}...` }); await downloadManager.downloadWithRetries( - ESP.URL.IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL, + pythonURLToUse, join(idfToolsDir, "dist"), pkgProgress, cancelToken @@ -163,6 +168,18 @@ export async function installIdfPython( const extractePyDestMsg = `Extracted ${idfPyDestPath} ...`; progress.report({ message: extractePyDestMsg }); OutputChannel.appendLine(extractePyDestMsg); - await spawn(join(idfPyDestPath, "python.exe"), ["-m", "ensurepip", "--upgrade"], { cwd: idfPyDestPath }); + if (idfVersion >= "5.0") { + await spawn( + join(idfPyDestPath, "python.exe"), + ["-m", "ensurepip", "--upgrade"], + { cwd: idfPyDestPath } + ); + } else { + await spawn(join(idfPyDestPath, "python.exe"), + ["-m", "pip", "install", "virtualenv"], + {cwd : idfPyDestPath} + ); + } + return join(idfPyDestPath, "python.exe"); } diff --git a/src/setup/espIdfDownloadStep.ts b/src/setup/espIdfDownloadStep.ts index 1163f0cdd..ab4042844 100644 --- a/src/setup/espIdfDownloadStep.ts +++ b/src/setup/espIdfDownloadStep.ts @@ -97,13 +97,9 @@ export async function expressInstall( const idfToolsManager = await IdfToolsManager.createIdfToolsManager( espIdfPath ); - const exportedToolsPaths = await idfToolsManager.exportPathsInString( - join(toolsPath, "tools"), - onReqPkgs - ); const toolsInfo = await idfToolsManager.getRequiredToolsInfo( join(toolsPath, "tools"), - exportedToolsPaths, + undefined, onReqPkgs ); SetupPanel.postMessage({ diff --git a/src/setup/toolsDownloadStep.ts b/src/setup/toolsDownloadStep.ts index 929a22386..9c0e22429 100644 --- a/src/setup/toolsDownloadStep.ts +++ b/src/setup/toolsDownloadStep.ts @@ -43,7 +43,7 @@ export async function downloadIdfTools( ); const requiredTools = await idfToolsManager.getRequiredToolsInfo( toolsPath, - exportPaths, + undefined, onReqPkgs ); SetupPanel.postMessage({ diff --git a/src/views/setup/ToolsCustom.vue b/src/views/setup/ToolsCustom.vue index eb6d1c822..92d1beaa0 100644 --- a/src/views/setup/ToolsCustom.vue +++ b/src/views/setup/ToolsCustom.vue @@ -5,7 +5,10 @@
- @@ -92,6 +95,7 @@ export default class CustomSetup extends Vue { } mounted() { + this.checkEspIdfTools(); const updatedToolsInfo = this.storeToolsResults.map((tool) => { if (tool.doesToolExist) { tool.progress = "100.00%"; diff --git a/src/views/setup/components/toolDownload.vue b/src/views/setup/components/toolDownload.vue index ffa051cde..fa0de7a3f 100644 --- a/src/views/setup/components/toolDownload.vue +++ b/src/views/setup/components/toolDownload.vue @@ -7,7 +7,7 @@
- + Checksum : {{ tool.hashResult ? "OK" : "Invalid" }}