summaryrefslogtreecommitdiff
path: root/buildscripts/scons.py
blob: f7f7fcd3d5b45851a0483830d52ddb417ad8bedb (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
"""Scons module."""

import os
import sys

SCONS_VERSION = os.environ.get('SCONS_VERSION', "3.1.2")

MONGODB_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
SCONS_DIR = os.path.join(MONGODB_ROOT, 'src', 'third_party', 'scons-' + SCONS_VERSION,
                         'scons-local-' + SCONS_VERSION)

if not os.path.exists(SCONS_DIR):
    print("Could not find SCons in '%s'" % (SCONS_DIR))
    sys.exit(1)

SITE_TOOLS_DIR = os.path.join(MONGODB_ROOT, 'site_scons')

sys.path = [SCONS_DIR, SITE_TOOLS_DIR] + sys.path

# pylint: disable=C0413
from mongo.pip_requirements import verify_requirements, MissingRequirements

try:
    verify_requirements('etc/pip/compile-requirements.txt')
except MissingRequirements as ex:
    print(ex)
    sys.exit(1)

try:
    import SCons.Script
except ImportError as import_err:
    print("Could not import SCons from '%s'" % (SCONS_DIR))
    print("ImportError:", import_err)
    sys.exit(1)


def entrypoint():
    SCons.Script.main()


if __name__ == '__main__':
    entrypoint()