[1082] | 1 | import os,sys
|
---|
| 2 | import distutils.sysconfig
|
---|
| 3 | import platform
|
---|
| 4 |
|
---|
| 5 | #vars = distutils.sysconfig.get_config_vars()
|
---|
| 6 | moduledir = "/tmp/dummy"#distutils.sysconfig.get_python_lib()
|
---|
| 7 |
|
---|
| 8 | opts = Options("userconfig.py", ARGUMENTS)
|
---|
| 9 | opts.Add("prefix", "The root installation path", distutils.sysconfig.PREFIX)
|
---|
| 10 | opts.Add("moduledir", "The python module path (site-packages))", moduledir)
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | def checkCasa(conf, path=None):
|
---|
| 14 | ''' look for casa libraries'''
|
---|
| 15 | conf.Message('Checking for casa libraries...')
|
---|
| 16 | casaarch = None
|
---|
| 17 | if os.environ.has_key('AIPSPATH'):
|
---|
| 18 | casa = os.environ.get('AIPSPATH').split()
|
---|
| 19 | conf.env.Append(CASAARCH = casa[1])
|
---|
| 20 | conf.env.Append(CASAROOT = casa[0])
|
---|
| 21 | conf.Result('yes')
|
---|
| 22 | return True
|
---|
| 23 | casaarch = 'linux_gnu'
|
---|
| 24 | if sys.platform == 'darwin':
|
---|
| 25 | casaarch = darwin
|
---|
| 26 | elif sys.platform == 'linux2' and platform.architecture()[0] == '64bit':
|
---|
| 27 | casarch = 'linux_64b'
|
---|
| 28 | paths = "/nfs/aips++/weekly /aips++ /opt/aips++ ../casa_asap".split()
|
---|
| 29 | if path is not None:
|
---|
| 30 | paths = [path]
|
---|
| 31 | for p in paths:
|
---|
| 32 | if os.path.isfile(os.path.join(p,casaarch,"lib/libcasa.a")):
|
---|
| 33 | conf.env.Append(CASAARCH = casaarch)
|
---|
| 34 | conf.env.Append(CASAROOT = p)
|
---|
| 35 | conf.Result('yes')
|
---|
| 36 | return True
|
---|
| 37 | conf.Result('n')
|
---|
| 38 | return False
|
---|
| 39 |
|
---|
| 40 | env = Environment( ENV = { 'PATH' : os.environ[ 'PATH' ],
|
---|
| 41 | 'HOME' : os.environ[ 'HOME' ] # required for distcc
|
---|
| 42 | }, options = opts)
|
---|
| 43 | env.Append(CASAARCH = '')
|
---|
| 44 | env.Append(CASAROOT = '')
|
---|
| 45 | if not env.GetOption('clean'):
|
---|
| 46 | conf = Configure(env,custom_tests = {'CheckCasa': checkCasa} )
|
---|
| 47 | pyvers = 'python'+distutils.sysconfig.get_python_version()
|
---|
| 48 | if not conf.CheckLib(library=pyvers, language='c'): Exit(1)
|
---|
| 49 | if not conf.CheckHeader(pyvers+'/Python.h', language='c'): Exit(1)
|
---|
| 50 | else: conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
|
---|
| 51 | #if not conf.CheckHeader(['boost/python.hpp'], language="C++"): Exit(1)
|
---|
| 52 | if not conf.CheckLib(library='boost_python', language='c++'): Exit(1)
|
---|
| 53 | # # if not conf.CheckLib('g2c'): Exit(1)
|
---|
| 54 | # # if not conf.CheckLib('lapack'): Exit(1)
|
---|
| 55 | # # if not conf.CheckLib('blas'): Exit(1)
|
---|
| 56 | # # if not conf.CheckLib('stdc++',language='c++'): Exit(1)
|
---|
| 57 | if not conf.CheckCasa(): Exit(1)
|
---|
| 58 | env = conf.Finish()
|
---|
| 59 | env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
|
---|
| 60 | if platform.architecture()[0] == '64bit':
|
---|
| 61 | env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B -DAIPS_GCC3'.split())
|
---|
| 62 |
|
---|
| 63 | #env.BuildDir('build', 'src')
|
---|
| 64 | Export("env")
|
---|
| 65 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
|
---|
| 66 | env.Install(moduledir, so )
|
---|
| 67 | env.Alias('install',moduledir)
|
---|