Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pythonManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export async function installPythonEnvFromIdfTools(
pythonBinPath: string,
gitPath: string,
context: ExtensionContext,
mirror: ESP.IdfMirror,
cancelToken?: CancellationToken
) {
const idfToolsPyPath = join(espDir, "tools", "idf_tools.py");
Expand All @@ -123,6 +124,9 @@ export async function installPythonEnvFromIdfTools(
);
modifiedEnv.IDF_TOOLS_PATH = idfToolsDir;
modifiedEnv.IDF_PATH = espDir;
if (mirror === ESP.IdfMirror.Espressif) {
modifiedEnv.PIP_INDEX_URL = "https://dl.espressif.cn/pypi";
}
if (process.platform === "win32") {
let pathToGitDir: string;
if (gitPath && gitPath !== "git") {
Expand Down
31 changes: 19 additions & 12 deletions src/setup/SetupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ export class SetupPanel {
message.toolsPath &&
message.pyBinPath &&
message.tools &&
message.saveScope
message.saveScope &&
typeof message.mirror !== undefined
) {
this.panel.webview.postMessage({
command: "updateEspIdfToolsStatus",
Expand All @@ -258,7 +259,8 @@ export class SetupPanel {
message.saveScope,
context,
setupArgs.workspaceFolder,
setupArgs.espIdfStatusBar
setupArgs.espIdfStatusBar,
message.mirror
);
}
break;
Expand All @@ -281,8 +283,9 @@ 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",
Expand Down Expand Up @@ -329,7 +332,10 @@ export class SetupPanel {

const pathIdfPy = path.join(message.path, "tools", "idf.py");
// Only require read and execute permissions
const fileExists = await canAccessFile(pathIdfPy, fs.constants.R_OK | fs.constants.X_OK);
const fileExists = await canAccessFile(
pathIdfPy,
fs.constants.R_OK | fs.constants.X_OK
);
if (!fileExists) {
this.panel.webview.postMessage({
command: "canAccessFileResponse",
Expand All @@ -349,8 +355,7 @@ export class SetupPanel {
versionEspIdf = await getEspIdfFromCMake(message.path);
}
// compareVersion returns a negative value if versionEspIdf is less than "5.0"
const noWhiteSpaceSupport =
compareVersion(versionEspIdf, "5.0") < 0;
const noWhiteSpaceSupport = compareVersion(versionEspIdf, "5.0") < 0;
const hasWhitespace = /\s/.test(message.path);
this.panel.webview.postMessage({
command: "canAccessFileResponse",
Expand Down Expand Up @@ -427,7 +432,7 @@ export class SetupPanel {
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
return await window.withProgress(
Expand Down Expand Up @@ -561,7 +566,7 @@ export class SetupPanel {
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
return await window.withProgress(
Expand Down Expand Up @@ -624,14 +629,15 @@ export class SetupPanel {
saveScope: ConfigurationTarget,
context: ExtensionContext,
workspaceFolderUri: Uri,
espIdfStatusBar: StatusBarItem
espIdfStatusBar: StatusBarItem,
mirror: ESP.IdfMirror
) {
const notificationMode = idfConf.readParameter(
"idf.notificationMode"
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
return await window.withProgress(
Expand Down Expand Up @@ -660,7 +666,8 @@ export class SetupPanel {
progress,
cancelToken,
workspaceFolderUri,
espIdfStatusBar
espIdfStatusBar,
mirror
);
} catch (error) {
this.setupErrHandler(error);
Expand Down
3 changes: 3 additions & 0 deletions src/setup/installPyReqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { OutputChannel } from "../logger/outputChannel";
import { PyReqLog } from "../PyReqLog";
import { CancellationToken, ExtensionContext, Progress } from "vscode";
import { Logger } from "../logger/logger";
import { ESP } from "../config";

export async function installPyReqs(
espIdfPath: string,
Expand All @@ -27,6 +28,7 @@ export async function installPyReqs(
gitPath: string,
context: ExtensionContext,
progress: Progress<{ message: string; increment?: number }>,
mirror: ESP.IdfMirror,
cancelToken?: CancellationToken
) {
progress.report({
Expand Down Expand Up @@ -68,6 +70,7 @@ export async function installPyReqs(
sysPyBinPath,
gitPath,
context,
mirror,
cancelToken
);
if (virtualEnvPyBin) {
Expand Down
5 changes: 4 additions & 1 deletion src/setup/pyReqsInstallStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { SetupPanel } from "./SetupPanel";
import { saveSettings } from "./setupInit";
import { getOpenOcdRules } from "./addOpenOcdRules";
import { addIdfPath } from "./espIdfJson";
import { ESP } from "../config";

export async function createPyReqs(
idfPath: string,
Expand All @@ -30,7 +31,8 @@ export async function createPyReqs(
progress: vscode.Progress<{ message: string; increment?: number }>,
cancelToken: vscode.CancellationToken,
workspaceFolderUri: vscode.Uri,
espIdfStatusBar: vscode.StatusBarItem
espIdfStatusBar: vscode.StatusBarItem,
mirror: ESP.IdfMirror
) {
SetupPanel.postMessage({
command: "updatePyVEnvStatus",
Expand All @@ -43,6 +45,7 @@ export async function createPyReqs(
gitPath,
context,
progress,
mirror,
cancelToken
);
await saveSettings(
Expand Down
3 changes: 2 additions & 1 deletion src/setup/toolsDownloadStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function downloadIdfTools(
progress,
cancelToken,
workspaceFolderUri,
espIdfStatusBar
espIdfStatusBar,
mirror
);
}
7 changes: 4 additions & 3 deletions src/views/setup/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ export const useSetupStore = defineStore("setup", () => {

function checkEspIdfTools() {
const pyPath =
selectedSysPython === pyVersionsList[pyVersionsList.value.length - 1]
? manualPythonPath
: selectedSysPython;
selectedSysPython.value === pyVersionsList.value[pyVersionsList.value.length - 1]
? manualPythonPath.value
: selectedSysPython.value;
console.log({
command: "checkEspIdfTools",
espIdf: espIdf.value,
Expand Down Expand Up @@ -254,6 +254,7 @@ export const useSetupStore = defineStore("setup", () => {
tools: JSON.stringify(toolsResults.value),
toolsPath: toolsFolder.value,
saveScope: saveScope.value,
mirror: selectedIdfMirror.value,
});
}

Expand Down