[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 |
|
---|
[1090] | 12 | def addCasaLibs(env):
|
---|
| 13 | casalibs = "casav atnf images ms components coordinates \
|
---|
| 14 | lattices fits measures measures_f \
|
---|
| 15 | tables scimath scimath_f casa wcs".split()
|
---|
| 16 | env.Prepend( LIBS = casalibs )
|
---|
| 17 | # Explicit templates in casa
|
---|
| 18 | env.Append( CPPFLAGS = ['-DAIPS_NO_TEMPLATE_SRC'] )
|
---|
[1082] | 19 |
|
---|
| 20 | def checkCasa(conf, path=None):
|
---|
| 21 | ''' look for casa libraries'''
|
---|
| 22 | conf.Message('Checking for casa libraries...')
|
---|
| 23 | casaarch = None
|
---|
| 24 | if os.environ.has_key('AIPSPATH'):
|
---|
| 25 | casa = os.environ.get('AIPSPATH').split()
|
---|
| 26 | conf.env.Append(CASAARCH = casa[1])
|
---|
| 27 | conf.env.Append(CASAROOT = casa[0])
|
---|
[1090] | 28 | addCasaLibs(conf.env)
|
---|
[1082] | 29 | conf.Result('yes')
|
---|
| 30 | return True
|
---|
| 31 | casaarch = 'linux_gnu'
|
---|
| 32 | if sys.platform == 'darwin':
|
---|
| 33 | casaarch = darwin
|
---|
| 34 | elif sys.platform == 'linux2' and platform.architecture()[0] == '64bit':
|
---|
| 35 | casarch = 'linux_64b'
|
---|
| 36 | paths = "/nfs/aips++/weekly /aips++ /opt/aips++ ../casa_asap".split()
|
---|
| 37 | if path is not None:
|
---|
| 38 | paths = [path]
|
---|
| 39 | for p in paths:
|
---|
| 40 | if os.path.isfile(os.path.join(p,casaarch,"lib/libcasa.a")):
|
---|
| 41 | conf.env.Append(CASAARCH = casaarch)
|
---|
| 42 | conf.env.Append(CASAROOT = p)
|
---|
[1090] | 43 | addCasaLibs(conf.env)
|
---|
[1082] | 44 | conf.Result('yes')
|
---|
| 45 | return True
|
---|
| 46 | conf.Result('n')
|
---|
| 47 | return False
|
---|
| 48 |
|
---|
| 49 | env = Environment( ENV = { 'PATH' : os.environ[ 'PATH' ],
|
---|
| 50 | 'HOME' : os.environ[ 'HOME' ] # required for distcc
|
---|
| 51 | }, options = opts)
|
---|
| 52 | env.Append(CASAARCH = '')
|
---|
| 53 | env.Append(CASAROOT = '')
|
---|
| 54 | if not env.GetOption('clean'):
|
---|
| 55 | conf = Configure(env,custom_tests = {'CheckCasa': checkCasa} )
|
---|
| 56 | pyvers = 'python'+distutils.sysconfig.get_python_version()
|
---|
| 57 | if not conf.CheckLib(library=pyvers, language='c'): Exit(1)
|
---|
| 58 | if not conf.CheckHeader(pyvers+'/Python.h', language='c'): Exit(1)
|
---|
| 59 | else: conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
|
---|
[1090] | 60 | if not conf.CheckHeader(['boost/python.hpp'], language="C++"): Exit(1)
|
---|
[1082] | 61 | if not conf.CheckLib(library='boost_python', language='c++'): Exit(1)
|
---|
[1090] | 62 | if not conf.CheckLib('rpfits'): Exit(1)
|
---|
| 63 | if not conf.CheckLib('cfitsio'): Exit(1)
|
---|
| 64 | if not conf.CheckLib('g2c'): Exit(1)
|
---|
| 65 | if not conf.CheckLib('lapack'): Exit(1)
|
---|
| 66 | if not conf.CheckLib('blas'): Exit(1)
|
---|
| 67 | if not conf.CheckLib('stdc++',language='c++'): Exit(1)
|
---|
[1082] | 68 | if not conf.CheckCasa(): Exit(1)
|
---|
| 69 | env = conf.Finish()
|
---|
[1090] | 70 | # general CPPFLAGS
|
---|
[1082] | 71 | env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
|
---|
[1090] | 72 | # 64bit flags
|
---|
[1082] | 73 | if platform.architecture()[0] == '64bit':
|
---|
[1090] | 74 | env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
|
---|
[1082] | 75 |
|
---|
| 76 | Export("env")
|
---|
| 77 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
|
---|
| 78 | env.Install(moduledir, so )
|
---|
[1090] | 79 | env.Install(moduledir, ["python/__init__.py"] )
|
---|
[1082] | 80 | env.Alias('install',moduledir)
|
---|