Skip to content

Commit 6013a28

Browse files
add python git github mirrors (#1586)
1 parent d4e6f30 commit 6013a28

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,17 @@ export namespace ESP {
9797
export namespace IDF_EMBED_GIT {
9898
export const VERSION = "2.39.2";
9999
export const IDF_EMBED_GIT_URL = `https://dl.espressif.com/dl/idf-git/idf-git-${VERSION}-win64.zip`;
100+
export const GITHUB_EMBED_GIT_URL = `https://github.com/git-for-windows/git/releases/download/v${VERSION}.windows.1/MinGit-${VERSION}-64-bit.zip`;
100101
}
101102
export namespace OLD_IDF_EMBED_PYTHON {
102103
export const VERSION = "3.8.7";
103104
export const IDF_EMBED_PYTHON_URL = `https://dl.espressif.com/dl/idf-python/idf-python-${VERSION}-embed-win64.zip`;
105+
export const GITHUB_EMBED_PYTHON_URL = `https://github.com/espressif/idf-python/releases/download/v${VERSION}/idf-python-${VERSION}-embed-win64.zip`;
104106
}
105107
export namespace IDF_EMBED_PYTHON {
106108
export const VERSION = "3.11.2";
107109
export const IDF_EMBED_PYTHON_URL = `https://dl.espressif.com/dl/idf-python/idf-python-${VERSION}-embed-win64.zip`;
110+
export const GITHUB_EMBED_PYTHON_URL = `https://github.com/espressif/idf-python/releases/download/v${VERSION}/idf-python-${VERSION}-embed-win64.zip`;
108111
}
109112
export const GithubRepository =
110113
"https://github.com/espressif/vscode-esp-idf-extension";

src/setup/SetupPanel.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ export class SetupPanel {
466466
const embedPaths = await this.installEmbedPyGit(
467467
toolsPath,
468468
idfVersion,
469+
mirror,
469470
progress,
470471
cancelToken
471472
);
@@ -585,6 +586,7 @@ export class SetupPanel {
585586
const embedPaths = await this.installEmbedPyGit(
586587
toolsPath,
587588
idfVersion,
589+
mirror,
588590
progress,
589591
cancelToken
590592
);
@@ -669,17 +671,24 @@ export class SetupPanel {
669671
private async installEmbedPyGit(
670672
toolsPath: string,
671673
idfVersion: string,
674+
mirror: ESP.IdfMirror,
672675
progress: Progress<{ message: string; increment?: number }>,
673676
cancelToken: CancellationToken
674677
) {
675-
const idfGitPath = await installIdfGit(toolsPath, progress, cancelToken);
678+
const idfGitPath = await installIdfGit(
679+
toolsPath,
680+
mirror,
681+
progress,
682+
cancelToken
683+
);
676684
SetupPanel.postMessage({
677685
command: "updateIdfGitStatus",
678686
status: StatusType.installed,
679687
});
680688
const idfPythonPath = await installIdfPython(
681689
toolsPath,
682690
idfVersion,
691+
mirror,
683692
progress,
684693
cancelToken
685694
);

src/setup/embedGitPy.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@ import { Logger } from "../logger/logger";
3636

3737
export async function installIdfGit(
3838
idfToolsDir: string,
39+
mirror: ESP.IdfMirror,
3940
progress?: Progress<{ message: string; increment?: number }>,
4041
cancelToken?: CancellationToken
4142
) {
4243
const downloadManager = new DownloadManager(idfToolsDir);
4344
const installManager = new InstallManager(idfToolsDir);
45+
let gitURLToUse =
46+
mirror === ESP.IdfMirror.Github
47+
? ESP.URL.IDF_EMBED_GIT.GITHUB_EMBED_GIT_URL
48+
: ESP.URL.IDF_EMBED_GIT.IDF_EMBED_GIT_URL;
4449
const idfGitZipPath = join(
4550
idfToolsDir,
4651
"dist",
47-
basename(ESP.URL.IDF_EMBED_GIT.IDF_EMBED_GIT_URL)
52+
basename(gitURLToUse)
4853
);
4954
const idfGitDestPath = join(
5055
idfToolsDir,
@@ -54,7 +59,7 @@ export async function installIdfGit(
5459
);
5560
const resultGitPath = join(idfGitDestPath, "cmd", "git.exe");
5661
const pkgProgress = new PackageProgress(
57-
basename(ESP.URL.IDF_EMBED_GIT.IDF_EMBED_GIT_URL),
62+
basename(gitURLToUse),
5863
sendIdfGitDownloadProgress,
5964
null,
6065
sendIdfGitDownloadDetail,
@@ -84,7 +89,7 @@ export async function installIdfGit(
8489
OutputChannel.appendLine(msgDownload);
8590
Logger.info(msgDownload);
8691
await downloadManager.downloadWithRetries(
87-
ESP.URL.IDF_EMBED_GIT.IDF_EMBED_GIT_URL,
92+
gitURLToUse,
8893
join(idfToolsDir, "dist"),
8994
pkgProgress,
9095
cancelToken
@@ -113,15 +118,24 @@ export async function installIdfGit(
113118
export async function installIdfPython(
114119
idfToolsDir: string,
115120
idfVersion: string,
121+
mirror: ESP.IdfMirror,
116122
progress?: Progress<{ message: string; increment?: number }>,
117123
cancelToken?: CancellationToken
118124
) {
119125
const downloadManager = new DownloadManager(idfToolsDir);
120126
const installManager = new InstallManager(idfToolsDir);
121-
const pythonURLToUse =
122-
idfVersion >= "5.0"
123-
? ESP.URL.IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL
124-
: ESP.URL.OLD_IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL;
127+
let pythonURLToUse: string;
128+
if (idfVersion >= "5.0") {
129+
pythonURLToUse =
130+
mirror === ESP.IdfMirror.Github
131+
? ESP.URL.IDF_EMBED_PYTHON.GITHUB_EMBED_PYTHON_URL
132+
: ESP.URL.IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL;
133+
} else {
134+
pythonURLToUse =
135+
mirror === ESP.IdfMirror.Github
136+
? ESP.URL.OLD_IDF_EMBED_PYTHON.GITHUB_EMBED_PYTHON_URL
137+
: ESP.URL.OLD_IDF_EMBED_PYTHON.IDF_EMBED_PYTHON_URL;
138+
}
125139
const idfPyZipPath = join(idfToolsDir, "dist", basename(pythonURLToUse));
126140
const pkgProgress = new PackageProgress(
127141
basename(pythonURLToUse),

0 commit comments

Comments
 (0)