Add a fix for python 3.12

The python extractor does not yet support 3.12. Check for this and
instead make sure we run python 3.11. Only need to check on windows
since we are extremely unlikely to be running 3.12 on linux or macos.
This commit is contained in:
Andrew Eisenberg
2023-10-06 12:24:49 -07:00
parent a2dc5ffaff
commit d0916526cd
7 changed files with 64 additions and 4 deletions

View File

@@ -17,7 +17,13 @@ import { CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { EnvVar } from "./environment";
import { Feature, Features } from "./feature-flags";
import { initCodeQL, initConfig, installPythonDeps, runInit } from "./init";
import {
checkInstallPython311,
initCodeQL,
initConfig,
installPythonDeps,
runInit,
} from "./init";
import { Language } from "./languages";
import { getActionsLogger, Logger } from "./logging";
import { parseRepositoryNwo } from "./repository";
@@ -277,6 +283,8 @@ async function run() {
logger,
);
await checkInstallPython311(config.languages);
if (
config.languages.includes(Language.python) &&
getRequiredInput("setup-python-dependencies") === "true"

View File

@@ -13,6 +13,7 @@ import {
FeatureEnablement,
useCodeScanningConfigInCli,
} from "./feature-flags";
import { Language } from "./languages";
import { Logger } from "./logging";
import { RepositoryNwo } from "./repository";
import { ToolsSource } from "./setup-codeql";
@@ -181,6 +182,23 @@ function processError(e: any): Error {
return e;
}
/**
* If we are running python 3.12+ on windows, we need to switch to python 3.11.
* This check happens in a powershell script.
*/
export async function checkInstallPython311(languages: Language[]) {
if (languages.includes(Language.python) && process.platform === "win32") {
const script = path.resolve(
__dirname,
"../python-setup",
"check_python12.ps1",
);
await new toolrunner.ToolRunner(await safeWhich.safeWhich("powershell"), [
script,
]).exec();
}
}
export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
logger.startGroup("Setup Python dependencies");