Changeset 1873 for trunk/SConstruct


Ignore:
Timestamp:
08/13/10 15:03:53 (14 years ago)
Author:
Malte Marquarding
Message:

Move to compile in pyrap out of external if it isn't found in the system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SConstruct

    r1819 r1873  
    44import platform
    55import SCons
     6
     7# try to autodetect numpy
     8def get_numpy_incdir():
     9    try:
     10        # try to find an egg
     11        from pkg_resources import require
     12        tmp = require("numpy")
     13        import numpy
     14        return numpy.__path__[0]+"/core/include"
     15    except Exception:
     16        # now try standard package
     17        try:
     18            import numpy
     19            return numpy.__path__[0]+"/core/include"
     20        except ImportError:
     21            pass
     22    return ""
    623
    724moduledir = distutils.sysconfig.get_python_lib()
     
    5875                ("pyraproot", "The root directory where libpyrap is installed",
    5976                 None),
     77                ("numpyincdir", "numpy header file directory",
     78                 get_numpy_incdir()),
    6079                ("pyraplib", "The name of the pyrap library", "pyrap"),
    6180                ("pyraplibdir", "The directory where libpyrap is installed",
     
    128147
    129148    conf.env.AddCustomPackage('pyrap')
    130     if  conf.env.get("enable_pyrap") and conf.CheckLib(conf.env["pyraplib"],
    131                                                        language='c++',
    132                                                        autoadd=0):
     149    if conf.CheckLib(conf.env["pyraplib"], language='c++', autoadd=0):
    133150        conf.env.Append(CPPFLAGS=['-DHAVE_PYRAP'])
    134151        conf.env.PrependUnique(LIBS=env['pyraplib'])
    135    
     152    else:
     153        conf.env.AppendUnique(CPPPATH=[conf.env["numpyincdir"]])
     154        # numpy 1.0 uses config.h; numpy >= 1.1 uses numpyconfig.h
     155        if conf.CheckHeader("numpy/config.h") or \
     156               conf.CheckHeader("numpy/numpyconfig.h"):
     157            conf.env.Append(CPPDEFINES=["-DAIPS_USENUMPY"])
     158        else:
     159            conf.env.Exit(1)
     160        # compile in pyrap here...
     161        conf.env["pyrapint"] = "#/external/libpyrap/pyrap-0.3.2"
    136162    # test for cfitsio
    137163    if not conf.CheckLib("m"): Exit(1)
Note: See TracChangeset for help on using the changeset viewer.