diff --git a/package.json b/package.json index ec9acf3bd..79992eea5 100644 --- a/package.json +++ b/package.json @@ -678,7 +678,7 @@ "type": "string", "default": "python", "description": "%param.pythonBinPath%", - "scope": "application" + "scope": "resource" }, "idf.flashBaudRate": { "type": "string", diff --git a/src/checkExtensionSettings.ts b/src/checkExtensionSettings.ts index 6608ea7d7..38dad3c12 100644 --- a/src/checkExtensionSettings.ts +++ b/src/checkExtensionSettings.ts @@ -80,6 +80,7 @@ export async function checkExtensionSettings( idfPath, gitPath, toolsPath: idfToolsPath, + sysPythonPath: "/usr/bin/python3", version: idfVersion, isValid: false, }; diff --git a/src/examples/ExamplesPanel.ts b/src/examples/ExamplesPanel.ts index dbe4e30a2..538ae5dfc 100644 --- a/src/examples/ExamplesPanel.ts +++ b/src/examples/ExamplesPanel.ts @@ -23,6 +23,7 @@ import { getExamplesList, IExampleCategory } from "./Example"; import { ComponentManagerUIPanel } from "../component-manager/panel"; import { OutputChannel } from "../logger/outputChannel"; import { IdfSetup } from "../views/setup/types"; +import { getSystemPythonFromSettings } from "../pythonManager"; export class ExamplesPlanel { public static currentPanel: ExamplesPlanel | undefined; @@ -122,8 +123,7 @@ export class ExamplesPlanel { ); await this.setCurrentSettingsInTemplate( settingsJsonPath, - idfSetup.idfPath, - idfSetup.toolsPath + idfSetup ); vscode.commands.executeCommand("vscode.openFolder", projectPath); } catch (error) { @@ -219,13 +219,21 @@ export class ExamplesPlanel { private async setCurrentSettingsInTemplate( settingsJsonPath: string, - idfPathDir: string, - toolsPath: string + idfSetup: IdfSetup ) { const settingsJson = await readJSON(settingsJsonPath); const isWin = process.platform === "win32" ? "Win" : ""; - settingsJson["idf.espIdfPath" + isWin] = idfPathDir; - settingsJson["idf.toolsPath" + isWin] = toolsPath; + settingsJson["idf.espIdfPath" + isWin] = idfSetup.idfPath; + settingsJson["idf.toolsPath" + isWin] = idfSetup.toolsPath; + if (idfSetup.python) { + settingsJson["idf.pythonInstallPath"] = await getSystemPythonFromSettings( + idfSetup.python, + idfSetup.idfPath, + idfSetup.toolsPath + ); + } else { + settingsJson["idf.pythonInstallPath"] = idfSetup.sysPythonPath; + } await writeJSON(settingsJsonPath, settingsJson, { spaces: vscode.workspace.getConfiguration().get("editor.tabSize") || 2, }); diff --git a/src/newProject/newProjectInit.ts b/src/newProject/newProjectInit.ts index c498503a7..3b0de33bf 100644 --- a/src/newProject/newProjectInit.ts +++ b/src/newProject/newProjectInit.ts @@ -27,8 +27,7 @@ import { getPreviousIdfSetups } from "../setup/existingIdfSetups"; import { IdfSetup } from "../views/setup/types"; export interface INewProjectArgs { - espIdfPath: string; - espIdfToolsPath: string; + espIdfSetup: IdfSetup; espAdfPath: string; espMdfPath: string; espMatterPath: string; @@ -149,9 +148,8 @@ export async function getNewProjectArgs( return { boards: espBoards, components, - espIdfToolsPath: idfSetup.toolsPath, + espIdfSetup: idfSetup, espAdfPath: adfExists ? espAdfPath : undefined, - espIdfPath: idfExists ? idfSetup.idfPath : undefined, espMdfPath: mdfExists ? espMdfPath : undefined, espMatterPath: matterExists ? espMatterPath : undefined, espHomeKitSdkPath: homekitSdkExists ? espHomeKitSdkPath : undefined, diff --git a/src/newProject/newProjectPanel.ts b/src/newProject/newProjectPanel.ts index 316779a05..b98513f94 100644 --- a/src/newProject/newProjectPanel.ts +++ b/src/newProject/newProjectPanel.ts @@ -22,6 +22,7 @@ import * as utils from "../utils"; import { IExample } from "../examples/Example"; import { setCurrentSettingsInTemplate } from "./utils"; import { NotificationMode, readParameter } from "../idfConfiguration"; +import { IdfSetup } from "../views/setup/types"; export class NewProjectPanel { public static currentPanel: NewProjectPanel | undefined; @@ -70,8 +71,8 @@ export class NewProjectPanel { if (newProjectArgs.espAdfPath) { localResourceRoots.push(vscode.Uri.file(newProjectArgs.espAdfPath)); } - if (newProjectArgs.espIdfPath) { - localResourceRoots.push(vscode.Uri.file(newProjectArgs.espIdfPath)); + if (newProjectArgs.espIdfSetup.idfPath) { + localResourceRoots.push(vscode.Uri.file(newProjectArgs.espIdfSetup.idfPath)); } if (newProjectArgs.espMdfPath) { localResourceRoots.push(vscode.Uri.file(newProjectArgs.espMdfPath)); @@ -124,8 +125,7 @@ export class NewProjectPanel { message.template ) { this.createProject( - newProjectArgs.espIdfPath, - newProjectArgs.espIdfToolsPath, + newProjectArgs.espIdfSetup, JSON.parse(message.components), message.port, message.containerFolder, @@ -199,8 +199,7 @@ export class NewProjectPanel { } private async createProject( - idfPath: string, - idfToolsPath: string, + idfSetup: IdfSetup, components: IComponent[], port: string, projectDirectory: string, @@ -287,8 +286,7 @@ export class NewProjectPanel { ); const settingsJson = await setCurrentSettingsInTemplate( settingsJsonPath, - idfPath, - idfToolsPath, + idfSetup, port, openOcdConfigs, workspaceFolder diff --git a/src/newProject/utils.ts b/src/newProject/utils.ts index 195a1d7a5..41b7daf90 100644 --- a/src/newProject/utils.ts +++ b/src/newProject/utils.ts @@ -19,11 +19,12 @@ import { readParameter } from "../idfConfiguration"; import { readJSON } from "fs-extra"; import { Uri } from "vscode"; +import { IdfSetup } from "../views/setup/types"; +import { getSystemPythonFromSettings } from "../pythonManager"; export async function setCurrentSettingsInTemplate( settingsJsonPath: string, - idfPathDir: string, - toolsPath: string, + idfSetup: IdfSetup, port: string, openOcdConfigs?: string, workspace?: Uri @@ -32,8 +33,17 @@ export async function setCurrentSettingsInTemplate( const adfPathDir = readParameter("idf.espAdfPath", workspace); const mdfPathDir = readParameter("idf.espMdfPath", workspace); const isWin = process.platform === "win32" ? "Win" : ""; - if (idfPathDir) { - settingsJson["idf.espIdfPath" + isWin] = idfPathDir; + if (idfSetup.idfPath) { + settingsJson["idf.espIdfPath" + isWin] = idfSetup.idfPath; + } + if (idfSetup.python) { + settingsJson["idf.pythonInstallPath"] = await getSystemPythonFromSettings( + idfSetup.python, + idfSetup.idfPath, + idfSetup.toolsPath + ); + } else { + settingsJson["idf.pythonInstallPath"] = idfSetup.sysPythonPath; } if (adfPathDir) { settingsJson["idf.espAdfPath" + isWin] = adfPathDir; @@ -50,8 +60,8 @@ export async function setCurrentSettingsInTemplate( if (port.indexOf("no port") === -1) { settingsJson["idf.port" + isWin] = port; } - if (toolsPath) { - settingsJson["idf.toolsPath" + isWin] = toolsPath; + if (idfSetup.toolsPath) { + settingsJson["idf.toolsPath" + isWin] = idfSetup.toolsPath; } return settingsJson; } diff --git a/src/pythonManager.ts b/src/pythonManager.ts index 111d24e95..b024ed3ee 100644 --- a/src/pythonManager.ts +++ b/src/pythonManager.ts @@ -141,12 +141,6 @@ export async function installPythonEnvFromIdfTools( }); } - await writeParameter( - "idf.pythonInstallPath", - pythonBinPath, - ConfigurationTarget.Global - ); - await execProcessWithLog( pythonBinPath, [idfToolsPyPath, "install-python-env"], @@ -309,7 +303,10 @@ export async function execProcessWithLog( } export async function getVirtualEnvPythonPath(workspaceFolder: Uri) { - let pythonPath = readParameter("idf.pythonInstallPath") as string; + let pythonPath = readParameter( + "idf.pythonInstallPath", + workspaceFolder + ) as string; let espIdfDir = readParameter("idf.espIdfPath", workspaceFolder) as string; let idfToolsDir = readParameter("idf.toolsPath", workspaceFolder) as string; const idfPathExists = await pathExists(espIdfDir); @@ -327,7 +324,10 @@ export async function getVirtualEnvPythonPath(workspaceFolder: Uri) { } export async function getPythonPath(workspaceFolder: Uri) { - let sysPythonBinPath = readParameter("idf.pythonInstallPath") as string; + let sysPythonBinPath = readParameter( + "idf.pythonInstallPath", + workspaceFolder + ) as string; const doesSysPythonBinPathExist = await pathExists(sysPythonBinPath); if (!doesSysPythonBinPathExist) { sysPythonBinPath = await getSystemPython(workspaceFolder); @@ -335,28 +335,27 @@ export async function getPythonPath(workspaceFolder: Uri) { await writeParameter( "idf.pythonInstallPath", sysPythonBinPath, - ConfigurationTarget.Global + workspaceFolder + ? ConfigurationTarget.WorkspaceFolder + : ConfigurationTarget.Global, + workspaceFolder ); } } return sysPythonBinPath; } -export async function getSystemPython(workspaceFolder: Uri) { - let pythonBinPath = readParameter( - "idf.pythonBinPath", - workspaceFolder - ) as string; +export async function getSystemPythonFromSettings( + pythonBinPath: string, + espIdfPath: string, + espIdfToolsPath: string +) { const pythonBinPathExists = await pathExists(pythonBinPath); if (pythonBinPathExists) { const pythonCode = `import sys; print('{}'.format(sys.base_prefix))`; const args = ["-c", pythonCode]; - const workingDir = - workspaceFolder && workspaceFolder.fsPath - ? workspaceFolder.fsPath - : __dirname; const pythonVersion = ( - await utils.execChildProcess(pythonBinPath, args, workingDir) + await utils.execChildProcess(pythonBinPath, args, __dirname) ).replace(/(\n|\r|\r\n)/gm, ""); const pyDir = process.platform === "win32" ? ["python.exe"] : ["bin", "python3"]; @@ -368,27 +367,37 @@ export async function getSystemPython(workspaceFolder: Uri) { const sysPythonBinPathList = await getUnixPythonList(__dirname); return sysPythonBinPathList.length ? sysPythonBinPathList[0] : "python3"; } else { - const idfPathDir = readParameter("idf.espIdfPath", workspaceFolder); - const idfToolsDir = readParameter( - "idf.toolsPath", - workspaceFolder - ) as string; - const idfVersion = await utils.getEspIdfFromCMake(idfPathDir); + const idfVersion = await utils.getEspIdfFromCMake(espIdfPath); const pythonVersionToUse = idfVersion >= "5.0" ? ESP.URL.IDF_EMBED_PYTHON.VERSION : ESP.URL.OLD_IDF_EMBED_PYTHON.VERSION; const idfPyDestPath = join( - idfToolsDir, + espIdfToolsPath, "tools", "idf-python", pythonVersionToUse, "python.exe" ); - return idfPyDestPath; + const idfPyDestExists = await pathExists(idfPyDestPath); + return idfPyDestExists ? idfPyDestPath : ""; } } +export async function getSystemPython(workspaceFolder: Uri) { + let pythonBinPath = readParameter( + "idf.pythonBinPath", + workspaceFolder + ) as string; + const idfPathDir = readParameter("idf.espIdfPath", workspaceFolder); + const idfToolsDir = readParameter("idf.toolsPath", workspaceFolder) as string; + return await getSystemPythonFromSettings( + pythonBinPath, + idfPathDir, + idfToolsDir + ); +} + export async function getPythonEnvPath( espIdfDir: string, idfToolsDir: string, @@ -412,8 +421,8 @@ export async function getPythonEnvPath( ? ["Scripts", "python.exe"] : ["bin", "python"]; const fullIdfPyEnvPath = join(idfPyEnvPath, ...pyDir); - - return fullIdfPyEnvPath; + const pyEnvPathExists = await pathExists(fullIdfPyEnvPath); + return pyEnvPathExists ? fullIdfPyEnvPath : ""; } export async function checkPythonExists(pythonBin: string, workingDir: string) { diff --git a/src/setup/existingIdfSetups.ts b/src/setup/existingIdfSetups.ts index 799f51616..06f8b7dc8 100644 --- a/src/setup/existingIdfSetups.ts +++ b/src/setup/existingIdfSetups.ts @@ -59,6 +59,7 @@ export async function clearPreviousIdfSetups() { export async function createIdfSetup( idfPath: string, toolsPath: string, + sysPythonBinPath: string, gitPath: string ) { const idfSetupId = getIdfMd5sum(idfPath); @@ -68,6 +69,7 @@ export async function createIdfSetup( idfPath, gitPath, toolsPath, + sysPythonPath: sysPythonBinPath, version: idfVersion, isValid: false, }; diff --git a/src/setup/pyReqsInstallStep.ts b/src/setup/pyReqsInstallStep.ts index cf489169c..8eb0b0493 100644 --- a/src/setup/pyReqsInstallStep.ts +++ b/src/setup/pyReqsInstallStep.ts @@ -19,7 +19,6 @@ import { SetupPanel } from "./SetupPanel"; import { saveSettings } from "./setupInit"; import { getOpenOcdRules } from "./addOpenOcdRules"; import { addIdfPath } from "./espIdfJson"; -import { writeParameter } from "../idfConfiguration"; export async function createPyReqs( idfPath: string, @@ -46,15 +45,11 @@ export async function createPyReqs( progress, cancelToken ); - await writeParameter( - "idf.pythonInstallPath", - pyPath, - vscode.ConfigurationTarget.Global - ); await saveSettings( idfPath, toolsPath, gitPath, + pyPath, saveScope, workspaceFolderUri, espIdfStatusBar diff --git a/src/setup/setupInit.ts b/src/setup/setupInit.ts index 7ac4a36f4..fe481a102 100644 --- a/src/setup/setupInit.ts +++ b/src/setup/setupInit.ts @@ -22,11 +22,7 @@ import { pathExists } from "fs-extra"; import path from "path"; import { Logger } from "../logger/logger"; import * as idfConf from "../idfConfiguration"; -import { - addIdfPath, - getPropertyFromJson, - getSelectedIdfInstalled, -} from "./espIdfJson"; +import { getPropertyFromJson, getSelectedIdfInstalled } from "./espIdfJson"; import { createIdfSetup, getPreviousIdfSetups, @@ -35,7 +31,6 @@ import { import { checkPyVenv } from "./setupValidation/pythonEnv"; import { packageJson } from "../utils"; import { getPythonPath, getVirtualEnvPythonPath } from "../pythonManager"; -import { getCurrentIdfSetup } from "../versionSwitcher"; import { CommandKeys, createCommandDictionary } from "../cmdTreeView/cmdStore"; export interface ISetupInitArgs { @@ -64,8 +59,6 @@ export interface IPreviousInstallResult { existingIdfSetups: IdfSetup[]; } -export interface IExistingSetup {} - export async function checkPreviousInstall( workspaceFolder: Uri ): Promise { @@ -232,12 +225,6 @@ export async function isCurrentInstallValid(workspaceFolder: Uri) { process.env.IDF_TOOLS_PATH || path.join(containerPath, ".espressif"); - // FIX use system Python path as setting instead venv - // REMOVE this line after next release - const sysPythonBinPath = await getPythonPath(workspaceFolder); - - const pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder); - let espIdfPath = idfConf.readParameter("idf.espIdfPath", workspaceFolder); let idfPathVersion = await utils.getEspIdfFromCMake(espIdfPath); if (idfPathVersion === "x.x" && process.platform === "win32") { @@ -288,6 +275,20 @@ export async function isCurrentInstallValid(workspaceFolder: Uri) { if (failedToolsResult.length !== 0) { return false; } + // FIX use system Python path as setting instead venv + // REMOVE this line after next release + const sysPythonBinPath = await getPythonPath(workspaceFolder); + + let pythonBinPath: string = ""; + if (sysPythonBinPath) { + pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder); + } + if (!pythonBinPath) { + pythonBinPath = idfConf.readParameter( + "idf.pythonBinPath", + workspaceFolder + ) as string; + } const isPyEnvValid = await checkPyVenv(pythonBinPath, espIdfPath); return isPyEnvValid; } @@ -296,9 +297,11 @@ export async function saveSettings( espIdfPath: string, toolsPath: string, gitPath: string, + sysPythonBinPath: string, saveScope: ConfigurationTarget, workspaceFolderUri: Uri, - espIdfStatusBar: StatusBarItem + espIdfStatusBar: StatusBarItem, + saveGlobalState: boolean = true ) { const confTarget = saveScope || @@ -324,13 +327,22 @@ export async function saveSettings( gitPath, ConfigurationTarget.Global ); - let currentIdfSetup = await createIdfSetup(espIdfPath, toolsPath, gitPath); + await idfConf.writeParameter( + "idf.pythonInstallPath", + sysPythonBinPath, + confTarget, + workspaceFolder + ); + const idfPathVersion = await utils.getEspIdfFromCMake(espIdfPath); + if (saveGlobalState) { + await createIdfSetup(espIdfPath, toolsPath, sysPythonBinPath, gitPath); + } if (espIdfStatusBar) { const commandDictionary = createCommandDictionary(); espIdfStatusBar.text = `$(${ commandDictionary[CommandKeys.SelectCurrentIdfVersion].iconId - }) ESP-IDF v` + currentIdfSetup.version; + }) ESP-IDF v` + idfPathVersion; } Logger.infoNotify("ESP-IDF has been configured"); } diff --git a/src/setup/setupValidation/espIdfSetup.ts b/src/setup/setupValidation/espIdfSetup.ts index 6267e2c61..3356c5217 100644 --- a/src/setup/setupValidation/espIdfSetup.ts +++ b/src/setup/setupValidation/espIdfSetup.ts @@ -24,8 +24,10 @@ import { pathExists } from "fs-extra"; import { Logger } from "../../logger/logger"; import { checkPyVenv } from "./pythonEnv"; import { ConfigurationTarget, StatusBarItem, Uri } from "vscode"; -import { getPythonEnvPath, getVirtualEnvPythonPath } from "../../pythonManager"; -import { readParameter } from "../../idfConfiguration"; +import { + getPythonEnvPath, + getSystemPythonFromSettings, +} from "../../pythonManager"; export async function useIdfSetupSettings( setupConf: IdfSetup, @@ -33,18 +35,32 @@ export async function useIdfSetupSettings( workspaceFolderUri: Uri, espIdfStatusBar: StatusBarItem ) { + let sysPythonBinPath = ""; + if (setupConf.python) { + sysPythonBinPath = await getSystemPythonFromSettings( + setupConf.python, + setupConf.idfPath, + setupConf.toolsPath + ); + } else { + sysPythonBinPath = setupConf.sysPythonPath; + } await saveSettings( setupConf.idfPath, setupConf.toolsPath, setupConf.gitPath, + sysPythonBinPath, saveScope, workspaceFolderUri, - espIdfStatusBar + espIdfStatusBar, + false ); } -export async function checkIdfSetup(setupConf: IdfSetup, - logToChannel: boolean = true) { +export async function checkIdfSetup( + setupConf: IdfSetup, + logToChannel: boolean = true +) { try { if (!setupConf.idfPath) { return false; @@ -75,8 +91,16 @@ export async function checkIdfSetup(setupConf: IdfSetup, if (failedToolsResult.length) { return false; } - let sysPythonBinPath = readParameter("idf.pythonInstallPath") as string; - const virtualEnvPython = await getPythonEnvPath(setupConf.idfPath, setupConf.toolsPath, sysPythonBinPath); + let virtualEnvPython = ""; + if (setupConf.python) { + virtualEnvPython = setupConf.python; + } else { + virtualEnvPython = await getPythonEnvPath( + setupConf.idfPath, + setupConf.toolsPath, + setupConf.sysPythonPath + ); + } const pyEnvReqs = await checkPyVenv(virtualEnvPython, setupConf.idfPath); return pyEnvReqs; diff --git a/src/test/project.test.ts b/src/test/project.test.ts index c7cb69e4c..ab1834fb9 100644 --- a/src/test/project.test.ts +++ b/src/test/project.test.ts @@ -29,6 +29,7 @@ import { setExtensionContext, updateProjectNameInCMakeLists, } from "../utils"; +import { IdfSetup } from "../views/setup/types"; suite("Project tests", () => { const absPath = (filename) => resolve(__dirname, "..", "..", filename); @@ -147,10 +148,15 @@ suite("Project tests", () => { assert.equal(settingsJson["idf.espIdfPath"], undefined); const openOcdConfigs = "interface/ftdi/esp32_devkitj_v1.cfg,target/esp32.cfg"; + + const idfSetup = { + idfPath: process.env.IDF_PATH, + toolsPath: process.env.IDF_TOOLS_PATH, + sysPythonPath: "python" + } as IdfSetup; const newSettingsJson = await setCurrentSettingsInTemplate( settingsJsonPath, - process.env.IDF_PATH, - process.env.IDF_TOOLS_PATH, + idfSetup, "no port", openOcdConfigs, Uri.file(projectPath) diff --git a/src/utils.ts b/src/utils.ts index 872c26989..986f5dcc0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -278,7 +278,6 @@ export async function setCCppPropertiesJsonCompilerPath( process.platform === "win32" ? "${config:idf.toolsPathWin}" : "${config:idf.toolsPath}"; - await updateCCppPropertiesJson( curWorkspaceFsPath, "compilerPath", @@ -322,10 +321,6 @@ export async function updateCCppPropertiesJson( cCppPropertiesJson.configurations && cCppPropertiesJson.configurations.length ) { - const buildDirPath = idfConf.readParameter( - "idf.buildPath", - workspaceUri - ) as string; cCppPropertiesJson.configurations[0][fieldToUpdate] = newFieldValue; await writeJSON(cCppPropertiesJsonPath, cCppPropertiesJson, { spaces: vscode.workspace.getConfiguration().get("editor.tabSize") || 2, @@ -1095,7 +1090,16 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) { ); } const sysPythonPath = await getPythonPath(curWorkspace); - const pythonBinPath = await getVirtualEnvPythonPath(curWorkspace); + let pythonBinPath = ""; + if (sysPythonPath) { + pythonBinPath = await getVirtualEnvPythonPath(curWorkspace); + } + if (!pythonBinPath) { + pythonBinPath = idfConf.readParameter( + "idf.pythonBinPath", + curWorkspace + ) as string; + } modifiedEnv.PYTHON = pythonBinPath || `${process.env.PYTHON}` || @@ -1294,9 +1298,10 @@ export async function startPythonReqsProcess( "tools", "check_python_dependencies.py" ); - const modifiedEnv = await appendIdfAndToolsToPath( - extensionContext.extensionUri + const modifiedEnv: { [key: string]: string } = <{ [key: string]: string }>( + Object.assign({}, process.env) ); + modifiedEnv.IDF_PATH = espIdfPath; return execChildProcess( pythonBinPath, [reqFilePath, "-r", requirementsPath], diff --git a/src/versionSwitcher/index.ts b/src/versionSwitcher/index.ts index d9de344da..e57c94392 100644 --- a/src/versionSwitcher/index.ts +++ b/src/versionSwitcher/index.ts @@ -26,7 +26,7 @@ import { readParameter } from "../idfConfiguration"; import { getIdfMd5sum } from "../setup/espIdfJson"; import { getEspIdfFromCMake } from "../utils"; import { IdfSetup } from "../views/setup/types"; -import { getPythonPath } from "../pythonManager"; +import { getPythonPath, getVirtualEnvPythonPath } from "../pythonManager"; export async function selectIdfSetup( workspaceFolder: Uri, @@ -61,8 +61,10 @@ export async function selectIdfSetup( return selectedIdfSetupOption.target; } -export async function getCurrentIdfSetup(workspaceFolder: Uri, - logToChannel: boolean = true) { +export async function getCurrentIdfSetup( + workspaceFolder: Uri, + logToChannel: boolean = true +) { const idfPath = readParameter("idf.espIdfPath", workspaceFolder); const toolsPath = readParameter("idf.toolsPath", workspaceFolder) as string; const gitPath = readParameter("idf.gitPath", workspaceFolder); @@ -70,6 +72,16 @@ export async function getCurrentIdfSetup(workspaceFolder: Uri, // FIX use system Python path as setting instead venv // REMOVE this line after neext release const sysPythonBinPath = await getPythonPath(workspaceFolder); + let pythonBinPath = ""; + if (sysPythonBinPath) { + pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder); + } + if (!pythonBinPath) { + pythonBinPath = readParameter( + "idf.pythonBinPath", + workspaceFolder + ) as string; + } const idfSetupId = getIdfMd5sum(idfPath); const idfVersion = await getEspIdfFromCMake(idfPath); @@ -78,6 +90,8 @@ export async function getCurrentIdfSetup(workspaceFolder: Uri, idfPath, gitPath, toolsPath, + sysPythonPath: sysPythonBinPath, + python: pythonBinPath, version: idfVersion, isValid: false, }; diff --git a/src/views/setup/types.ts b/src/views/setup/types.ts index cdacae4cc..a43d90868 100644 --- a/src/views/setup/types.ts +++ b/src/views/setup/types.ts @@ -29,6 +29,8 @@ export interface IdfSetup { toolsPath: string; idfPath: string; gitPath: string; + python?: string; + sysPythonPath?: string; isValid: boolean; } diff --git a/testFiles/testWorkspace/.vscode/c_cpp_properties.json b/testFiles/testWorkspace/.vscode/c_cpp_properties.json old mode 100644 new mode 100755 diff --git a/testFiles/testWorkspace/.vscode/settings.json b/testFiles/testWorkspace/.vscode/settings.json index c8fecd193..eb2b2f032 100644 --- a/testFiles/testWorkspace/.vscode/settings.json +++ b/testFiles/testWorkspace/.vscode/settings.json @@ -12,5 +12,5 @@ "window.dialogStyle": "custom", "idf.notificationMode": "Output", "idf.showOnboardingOnInit": false, - "idf.pythonInstallPath": "python" + "idf.pythonInstallPath": "/usr/bin/python3" } \ No newline at end of file