Changeset 1873


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

Location:
trunk
Files:
2 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)
  • trunk/src/SConscript

    r1819 r1873  
    88cpps = env.SGlob("*.cpp")
    99pycpps = env.SGlob("python_*.cpp")
    10 for pf in pycpps: cpps.remove(pf)
     10for pf in pycpps:
     11    cpps.remove(pf)
    1112
    1213# location of libcasav.a
     
    1819myenv.Prepend( LIBS =  ['asap'] )
    1920
     21shenv = myenv.Clone()
     22pyrapdir = shenv.get("pyrapint", None)
     23if pyrapdir:
     24    shenv.PrependUnique(CPPPATH=pyrapdir)   
     25    pycpps += shenv.Glob('%s/pyrap/*/*.cc' % pyrapdir)
    2026# Finally create the library for the module
    21 if not hasattr(myenv, "LoadableModule"):
    22     myenv.LoadableModule = myenv.SharedLibrary
    23 so = myenv.LoadableModule( target = "_asap.so", source = pycpps, SHLIBSUFFIX="" )
    24 #test = myenv.Program("test", cpps)
     27if not hasattr(shenv, "LoadableModule"):
     28    shenv.LoadableModule = shenv.SharedLibrary
     29so = shenv.LoadableModule( target = "_asap.so", source = pycpps, SHLIBSUFFIX="" )
     30#test = shenv.Program("test", cpps)
    2531Return("so")
    2632
Note: See TracChangeset for help on using the changeset viewer.