Skip to content

Commit b8e9231

Browse files
committed
Use pre-built Python 3.7 for Windows 7 and below
1 parent a49f40e commit b8e9231

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/installer/get-python.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { callInstallerScript } from './get-platformio';
1313
import crypto from 'crypto';
1414
import fs from 'fs';
1515
import got from 'got';
16+
import os from 'os';
1617
import path from 'path';
1718
import { promisify } from 'util';
1819
import semver from 'semver';
@@ -61,6 +62,13 @@ export async function installPortablePython(destinationDir) {
6162
if (!archivePath) {
6263
throw new Error('Could not download portable Python');
6364
}
65+
try {
66+
await fs.promises.rmdir(destinationDir, {
67+
recursive: true,
68+
});
69+
} catch (err) {
70+
console.warn(err);
71+
}
6472
await extractTarGz(archivePath, destinationDir);
6573
await ensurePythonExeExists(destinationDir);
6674
return destinationDir;
@@ -88,6 +96,20 @@ async function getRegistryFile() {
8896
}
8997

9098
function isVersionSystemCompatible(version, systype) {
99+
// ignore Python >=3.9 on <= Win7
100+
try {
101+
const originVersion = parseInt(version.name.split('.')[1]);
102+
if (
103+
proc.IS_WINDOWS &&
104+
originVersion >= 30900 &&
105+
semver.satisfies(os.release(), '<=6.1')
106+
) {
107+
return false;
108+
}
109+
} catch (err) {
110+
console.warn(err);
111+
}
112+
91113
for (const item of version.files) {
92114
if (item.system.includes(systype)) {
93115
return true;

0 commit comments

Comments
 (0)