summaryrefslogtreecommitdiff
path: root/jstests/libs/python.js
blob: 0d80daf07853be2da0c53aca9ec1a76fd93c3f99 (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/v4/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";
}