Skip to content

Commit 3ff1fd9

Browse files
committed
Python-Setup: set PYTHONDONTWRITEBYTECODE=1
1 parent 47bcabd commit 3ff1fd9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/init.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
240240
const scriptsFolder = path.resolve(__dirname, "../python-setup");
241241

242242
try {
243+
const env = { ...process.env, PYTHONDONTWRITEBYTECODE: "1" };
243244
if (process.platform === "win32") {
244245
await new toolrunner.ToolRunner(await safeWhich.safeWhich("powershell"), [
245246
path.join(scriptsFolder, "install_tools.ps1"),
246-
]).exec();
247+
], { env: env }).exec();
247248
} else {
248249
await new toolrunner.ToolRunner(
249-
path.join(scriptsFolder, "install_tools.sh")
250+
path.join(scriptsFolder, "install_tools.sh"), [], { env: env }
250251
).exec();
251252
}
252253
const script = "auto_install_packages.py";
@@ -255,19 +256,19 @@ export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
255256
"-3",
256257
path.join(scriptsFolder, script),
257258
path.dirname(codeql.getPath()),
258-
]).exec();
259+
], { env: env }).exec();
259260
} else {
260261
await new toolrunner.ToolRunner(path.join(scriptsFolder, script), [
261262
path.dirname(codeql.getPath()),
262-
]).exec();
263+
], { env: env }).exec();
263264
}
264265
} catch (e) {
265266
logger.endGroup();
266267
logger.warning(
267268
`An error occurred while trying to automatically install Python dependencies: ${e}\n` +
268-
"Please make sure any necessary dependencies are installed before calling the codeql-action/analyze " +
269-
"step, and add a 'setup-python-dependencies: false' argument to this step to disable our automatic " +
270-
"dependency installation and avoid this warning."
269+
"Please make sure any necessary dependencies are installed before calling the codeql-action/analyze " +
270+
"step, and add a 'setup-python-dependencies: false' argument to this step to disable our automatic " +
271+
"dependency installation and avoid this warning."
271272
);
272273
return;
273274
}

0 commit comments

Comments
 (0)