Files
mongo/jstests/libs/python.js
Alexander Neben 5c9907ee29 SERVER-79624 Upgrade windows python to 3.10 (#14742)
GitOrigin-RevId: 9a40aaf2801da426b65b778e2865f063864fdcd5
2024-02-01 18:48:38 +00:00

34 lines
1.1 KiB
JavaScript

// Helper for finding the local python binary.
export function getPython3Binary() {
// On windows it is important to use python vs python3
// or else we will pick up a python that is not in our venv
clearRawMongoProgramOutput();
assert.eq(runNonMongoProgram("python", "--version"), 0);
const pythonVersion = rawMongoProgramOutput(); // Will look like "Python 3.10.4\n"
const usingPython310 = /Python 3\.10/.exec(pythonVersion);
if (usingPython310) {
print(
"Found python 3.10 by default. Likely this is because we are using a virtual enviorment.");
return "python";
}
const paths = [
"/opt/mongodbtoolchain/v4/bin/python3",
"/cygdrive/c/python/python310/python.exe",
"c:/python/python310/python.exe"
];
for (let p of paths) {
if (fileExists(p)) {
print("Found python3 in default location " + p);
return p;
}
}
assert(/Python 3/.exec(pythonVersion));
// We are probs running on mac
print("Did not find python3 in a virtualenv or default location");
return "python3";
}