summaryrefslogtreecommitdiff
path: root/jstests/libs/python.js
blob: f046d4df30c196c09d054719da05501cc748c853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Helper for finding the local python binary.

function getPython3Binary() {
    'use strict';

    let cmd = '/opt/mongodbtoolchain/v3/bin/python3';
    if (_isWindows()) {
        const paths = ["c:/python36/python.exe", "c:/python/python36/python.exe"];
        for (let p of paths) {
            if (fileExists(p)) {
                cmd = p;
                break;
            }
        }
    }

    if (fileExists(cmd)) {
        return cmd;
    }

    clearRawMongoProgramOutput();
    assert.eq(runNonMongoProgram("python", "--version"), 0);
    const pythonVersion = rawMongoProgramOutput();
    assert(/Python 3/.exec(pythonVersion));

    return "python";
}