Merge pull request #4650 from Repiteo/node-explicit-types
[scons.git] / scripts / scons.py
blob9c5be9d4840b6f5afa0f8b8f7e9832b915bdeec5
1 #! /usr/bin/env python
3 # SCons - a Software Constructor
5 # MIT License
7 # Copyright The SCons Foundation
9 # Permission is hereby granted, free of charge, to any person obtaining
10 # a copy of this software and associated documentation files (the
11 # "Software"), to deal in the Software without restriction, including
12 # without limitation the rights to use, copy, modify, merge, publish,
13 # distribute, sublicense, and/or sell copies of the Software, and to
14 # permit persons to whom the Software is furnished to do so, subject to
15 # the following conditions:
17 # The above copyright notice and this permission notice shall be included
18 # in all copies or substantial portions of the Software.
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
21 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
22 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
28 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30 __version__ = "__VERSION__"
32 __build__ = "__BUILD__"
34 __buildsys__ = "__BUILDSYS__"
36 __date__ = "__DATE__"
38 __developer__ = "__DEVELOPER__"
41 import os
42 import sys
44 # Python compatibility check
45 if sys.version_info < (3, 7, 0):
46 msg = "scons: *** SCons version %s does not run under Python version %s.\n\
47 Python >= 3.7.0 is required.\n"
48 sys.stderr.write(msg % (__version__, sys.version.split()[0]))
49 sys.exit(1)
51 # Strip the script directory from sys.path so on case-insensitive
52 # (WIN32) systems Python doesn't think that the "scons" script is the
53 # "SCons" package.
54 script_dir = os.path.dirname(os.path.realpath(__file__))
55 script_path = os.path.realpath(os.path.dirname(__file__))
56 if script_path in sys.path:
57 sys.path.remove(script_path)
59 libs = []
61 if "SCONS_LIB_DIR" in os.environ:
62 libs.append(os.environ["SCONS_LIB_DIR"])
64 # running from source takes 2nd priority (since 2.3.2), following SCONS_LIB_DIR
65 source_path = os.path.join(script_path, os.pardir)
66 if os.path.isdir(source_path):
67 libs.append(source_path)
69 # add local-install locations
70 local_version = 'scons-local-' + __version__
71 local = 'scons-local'
72 if script_dir:
73 local_version = os.path.join(script_dir, local_version)
74 local = os.path.join(script_dir, local)
75 if os.path.isdir(local_version):
76 libs.append(os.path.abspath(local_version))
77 if os.path.isdir(local):
78 libs.append(os.path.abspath(local))
80 sys.path = libs + sys.path
82 ##############################################################################
83 # END STANDARD SCons SCRIPT HEADER
84 ##############################################################################
86 if __name__ == "__main__":
87 try:
88 import SCons.Script
89 except ImportError:
90 sys.stderr.write("SCons import failed. Unable to find engine files in:\n")
91 for path in libs:
92 sys.stderr.write(" {}\n".format(path))
93 raise
95 # this does all the work, and calls sys.exit
96 # with the proper exit status when done.
97 SCons.Script.main()
99 # Local Variables:
100 # tab-width:4
101 # indent-tabs-mode:nil
102 # End:
103 # vim: set expandtab tabstop=4 shiftwidth=4: