1 | import os |
---|
2 | import sys |
---|
3 | |
---|
4 | # Read in build options |
---|
5 | opts = Options('build_options.py') |
---|
6 | opts.Add('GCCFLAGS', 'Flags passed to GCC') |
---|
7 | opts.Add('MSVCFLAGS', 'Flags passed to the MSVC compiler') |
---|
8 | |
---|
9 | env = Environment(options = opts) |
---|
10 | |
---|
11 | Help(opts.GenerateHelpText(env)) |
---|
12 | |
---|
13 | # Find the path for Python.h and then share it to other SConscripts later on |
---|
14 | # Where to find the Python.h |
---|
15 | if sys.platform == 'win32': |
---|
16 | # Prefer MinGW over MSVC |
---|
17 | Tool('mingw')(env) |
---|
18 | |
---|
19 | python_include = os.path.join(sys.exec_prefix, 'include') |
---|
20 | # Windows installs need to be told the lib path and the python library name |
---|
21 | # else it won't work right. |
---|
22 | python_libdir = os.path.join(sys.exec_prefix, 'libs') |
---|
23 | env.Append(LIBPATH=[python_libdir]) |
---|
24 | python_libname = 'python%d%d' % (sys.version_info[0:2]) |
---|
25 | env.Append(LIBS=[python_libname]) |
---|
26 | else: |
---|
27 | python_include = os.path.join(os.path.join(sys.exec_prefix, 'include'), |
---|
28 | 'python' + sys.version[:3]) |
---|
29 | |
---|
30 | # Check existence of Python.h |
---|
31 | headerfile = python_include + os.sep + 'Python.h' |
---|
32 | try: |
---|
33 | open(headerfile, 'r') |
---|
34 | except: |
---|
35 | raise """Did not find Python header file %s. |
---|
36 | Make sure files for Python C-extensions are installed. |
---|
37 | In debian linux, for example, you need to install a |
---|
38 | package called something like python2.3-dev""" %headerfile |
---|
39 | |
---|
40 | env.Append(CPPPATH=[python_include]) |
---|
41 | |
---|
42 | # Set appropriate CCFLAGS for the compiler. |
---|
43 | if env['CC'] == 'gcc': |
---|
44 | env.Append(CCFLAGS=['${GCCFLAGS}']) |
---|
45 | elif env['CC'] == 'cl': |
---|
46 | env.Append(CCFLAGS=['${MSVCFLAGS}']) |
---|
47 | |
---|
48 | Export('env') |
---|
49 | |
---|
50 | SConscript(['inundation/SConscript']) |
---|