Skip to content

Commit

Permalink
add both venv sys python
Browse files Browse the repository at this point in the history
  • Loading branch information
brianignacio5 committed Jan 14, 2025
1 parent 1822039 commit 3d1537e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/checkExtensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function checkExtensionSettings(
idfPath,
gitPath,
toolsPath: idfToolsPath,
sysPythonPath: "python",
sysPythonPath: "/usr/bin/python3",
version: idfVersion,
isValid: false,
};
Expand Down
25 changes: 16 additions & 9 deletions src/setup/setupInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,15 @@ export async function isCurrentInstallValid(workspaceFolder: Uri) {
// REMOVE this line after next release
const sysPythonBinPath = await getPythonPath(workspaceFolder);

const pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder);
let pythonBinPath: string = "";
if (sysPythonBinPath) {
pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder);
} else {
pythonBinPath = idfConf.readParameter(
"idf.pythonBinPath",
workspaceFolder
) as string;
}

let espIdfPath = idfConf.readParameter("idf.espIdfPath", workspaceFolder);
let idfPathVersion = await utils.getEspIdfFromCMake(espIdfPath);
Expand Down Expand Up @@ -294,7 +302,8 @@ export async function saveSettings(
sysPythonBinPath: string,
saveScope: ConfigurationTarget,
workspaceFolderUri: Uri,
espIdfStatusBar: StatusBarItem
espIdfStatusBar: StatusBarItem,
saveGlobalState: boolean = true
) {
const confTarget =
saveScope ||
Expand Down Expand Up @@ -326,18 +335,16 @@ export async function saveSettings(
confTarget,
workspaceFolder
);
let currentIdfSetup = await createIdfSetup(
espIdfPath,
toolsPath,
sysPythonBinPath,
gitPath
);
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");
}
19 changes: 12 additions & 7 deletions src/setup/setupValidation/espIdfSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { Logger } from "../../logger/logger";
import { checkPyVenv } from "./pythonEnv";
import { ConfigurationTarget, StatusBarItem, Uri } from "vscode";
import { getPythonEnvPath } from "../../pythonManager";
import { readParameter } from "../../idfConfiguration";

export async function useIdfSetupSettings(
setupConf: IdfSetup,
Expand All @@ -40,7 +39,8 @@ export async function useIdfSetupSettings(
setupConf.sysPythonPath,
saveScope,
workspaceFolderUri,
espIdfStatusBar
espIdfStatusBar,
false
);
}

Expand Down Expand Up @@ -78,11 +78,16 @@ export async function checkIdfSetup(
if (failedToolsResult.length) {
return false;
}
const virtualEnvPython = await getPythonEnvPath(
setupConf.idfPath,
setupConf.toolsPath,
setupConf.sysPythonPath
);
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;
Expand Down
9 changes: 3 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ export async function setCCppPropertiesJsonCompilerPath(
process.platform === "win32"
? "${config:idf.toolsPathWin}"
: "${config:idf.toolsPath}";

console.log(
`BLaBLABLA setCCppPropertiesJsonCompilerPath ${curWorkspaceFsPath.fsPath}`
);
await updateCCppPropertiesJson(
curWorkspaceFsPath,
"compilerPath",
Expand Down Expand Up @@ -1275,9 +1271,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],
Expand Down
3 changes: 2 additions & 1 deletion src/views/setup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export interface IdfSetup {
toolsPath: string;
idfPath: string;
gitPath: string;
sysPythonPath: string;
python?: string;
sysPythonPath?: string;
isValid: boolean;
}

Expand Down

0 comments on commit 3d1537e

Please sign in to comment.