import os import sys # Read in build options opts = Options('build_options.py') opts.Add('CFLAGS', 'Flags passed to the C Compiler') env = Environment(options = opts, CCFLAGS=['${CFLAGS}']) Help(opts.GenerateHelpText(env)) # Find the path for Python.h and then share it to other SConscripts later on # Where to find the Python.h if sys.platform == 'win32': # Prefer MinGW over MSVC env['TOOLS'] = 'mingw' python_include = os.path.join(sys.exec_prefix, 'include') # Windows installs need to be told the lib path and the python library name # else it won't work right. python_libdir = os.path.join(sys.exec_prefix, 'libs') try: env['LIBPATH'] += [python_libdir] except KeyError: env['LIBPATH'] = [python_libdir] python_libname = 'python%d%d' % (sys.version_info[0], sys.version_info[1]) try: env['LIBS'] += [python_libname] except KeyError: env['LIBS'] = [python_libname] else: python_include = os.path.join(os.path.join(sys.exec_prefix, 'include'), 'python' + sys.version[:3]) # Check existence of Python.h headerfile = python_include + os.sep + 'Python.h' try: open(headerfile, 'r') except: raise """Did not find Python header file %s. Make sure files for Python C-extensions are installed. In debian linux, for example, you need to install a package called something like python2.3-dev""" %headerfile try: env['CPPPATH'] += [python_include] except KeyError: env['CPPPATH'] = [python_include] Export('env') SConscript(['inundation/SConscript'])