Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use older embed python for older that idf 5 #1021

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
20 changes: 19 additions & 1 deletion src/setup/SetupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -369,8 +369,22 @@ 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.match(/v(.+)/g);
if (matches && matches.length) {
idfVersion = matches[1];
} else {
idfVersion = "5.0";
}
}
const embedPaths = await this.installEmbedPyGit(
toolsPath,
idfVersion,
progress,
cancelToken
);
Expand Down Expand Up @@ -484,8 +498,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
);
Expand Down Expand Up @@ -561,6 +577,7 @@ export class SetupPanel {

private async installEmbedPyGit(
toolsPath: string,
idfVersion: string,
progress: vscode.Progress<{ message: string; increment?: number }>,
cancelToken: vscode.CancellationToken
) {
Expand All @@ -571,6 +588,7 @@ export class SetupPanel {
});
const idfPythonPath = await installIdfPython(
toolsPath,
idfVersion,
progress,
cancelToken
);
Expand Down
29 changes: 19 additions & 10 deletions src/setup/embedGitPy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -163,6 +168,10 @@ 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 });
await spawn(
join(idfPyDestPath, "python.exe"),
["-m", "ensurepip", "--upgrade"],
{ cwd: idfPyDestPath }
);
return join(idfPyDestPath, "python.exe");
}