/[escript]/branches/escript3047_with_pastix2995/SConstruct
ViewVC logotype

Diff of /branches/escript3047_with_pastix2995/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1232 by phornby, Fri Aug 10 06:44:04 2007 UTC revision 1250 by ksteube, Thu Aug 16 02:54:42 2007 UTC
# Line 15  EnsurePythonVersion(2,3) Line 15  EnsurePythonVersion(2,3)
15  #===============================================================  #===============================================================
16  #   import tools:  #   import tools:
17  import glob  import glob
18  import sys, os  import sys, os, re
 import socket  
19  # Add our extensions  # Add our extensions
20  if sys.path.count('scons')==0: sys.path.append('scons')  if sys.path.count('scons')==0: sys.path.append('scons')
21  import scons_extensions  import scons_extensions
# Line 29  tools_prefix="/usr" Line 28  tools_prefix="/usr"
28  #      #    
29  #    get the installation prefix  #    get the installation prefix
30  #  #
31  prefix = ARGUMENTS.get('prefix', Dir('#.').abspath)  prefix = ARGUMENTS.get('prefix', '/usr')
32    
33  # We may also need to know where python's site-packages subdirectory lives  # We may also need to know where python's site-packages subdirectory lives
34  python_version = 'python%s.%s'%(sys.version_info[0],sys.version_info[1])  python_version = 'python%s.%s'%(sys.version_info[0],sys.version_info[1])
35    
36  if prefix == "/usr":  # Install as a standard python package in /usr/lib64 if available, else in /usr/lib
37     # Install as a standard python package in /usr/lib64 if available, else in /usr/lib  if os.path.isdir(  prefix+"/lib64/"+python_version+"/site-packages"):
38     if os.path.isdir(  prefix+"/lib64/"+python_version+"/site-packages"):     sys_dir_packages =  prefix+"/lib64/"+python_version+"/site-packages/esys"
39        dir_packages =  prefix+"/lib64/"+python_version+"/site-packages"     sys_dir_libraries = prefix+"/lib64"
40        dir_libraries = prefix+"/lib64"  else:
41     elif os.path.isdir(prefix+"/lib/"+python_version+"/site-packages"):     sys_dir_packages =  prefix+"/lib/"+python_version+"/site-packages/esys"
42        dir_packages =  prefix+"/lib/"+python_version+"/site-packages"     sys_dir_libraries = prefix+"/lib"
43        dir_libraries = prefix+"/lib"  
44     else:  sys_dir_examples = prefix+"/share/doc/esys"
45        print "Install prefix is /usr but couldn't find python package directory in either"  
46        print "/usr/lib64/"+python_version+"/site-packages or /usr/lib/"+python_version+"/site-packages"  source_root = Dir('#.').abspath
       sys.exit(1)  
    dir_examples = prefix+"/share/doc/esys"  
 else:  
    # Install using the usual escript directory structure  
    dir_packages = prefix  
    dir_libraries = prefix+"/lib"  
    dir_examples = prefix  
 dir_packages += "/esys"  
 dir_examples += "/examples"  
47    
48    dir_packages = os.path.join(source_root,"esys")
49    dir_examples = os.path.join(source_root,"examples")
50    dir_libraries = os.path.join(source_root,"lib")
51    
52    print " Default packages local installation:    ", dir_packages
53    print " Default library local installation  ", dir_libraries
54    print " Default example local  installation:    ", dir_examples
55  print "Install prefix is: ", prefix  print "Install prefix is: ", prefix
56  print " python packages will be installed in:   ", dir_packages  print " Default packages system installation:   ", sys_dir_packages
57  print " libraries will be installed in:     ", dir_libraries  print " Default library system installation     ", sys_dir_libraries
58  print " examples will be installed in:      ", dir_examples  print " Default example system installation:    ", sys_dir_examples
59    
60  #==============================================================================================      #==============================================================================================    
61    
# Line 71  print "    examples will be installed in: Line 68  print "    examples will be installed in:
68  #      #    
69  #    get the options file if present:  #    get the options file if present:
70  #  #
71  if ARGUMENTS.get('options_file',0):  options_file = ARGUMENTS.get('options_file','')
72     options_file = ARGUMENTS.get('options_file',0)  
73  else:  if not os.path.isfile(options_file) :
74     from string import ascii_letters,digits      options_file = False
75     hostname=""  
76     for s in socket.gethostname().split('.')[0]:  if not options_file :
77        if s in ascii_letters+digits:     import socket
78           hostname+=s     hostname = re.sub("[^0-9a-zA-Z]", "_", socket.gethostname().split('.')[0])
79        else:     tmp = os.path.join("scons",hostname+"_options.py")
80           hostname+="_"  
81     options_file = os.path.join("scons",hostname+"_options.py")     if os.path.isfile(tmp) :
82            options_file = tmp
83  if os.path.isfile(options_file):  
84     print "option file is ",options_file,"."  IS_WINDOWS_PLATFORM = (os.name== "nt")
85  else:  
86     print "option file is ",options_file, "(not present)."  # If you're not going to tell me then......
87    # FIXME: add one for the altix too.
88    if not options_file :
89       if IS_WINDOWS_PLATFORM :
90          options_file = "scons/windows_mscv71_options.py"
91       else:
92          options_file = "scons/linux_gcc_eg_options.py"
93    
94  # and load it  # and load it
95  opts = Options(options_file, ARGUMENTS)  opts = Options(options_file, ARGUMENTS)
96  #================================================================  #================================================================
# Line 122  else: Line 126  else:
126  #  #
127  python_path_default=os.path.join(tools_prefix,'include','python%s.%s'%(sys.version_info[0],sys.version_info[1]))  python_path_default=os.path.join(tools_prefix,'include','python%s.%s'%(sys.version_info[0],sys.version_info[1]))
128  python_lib_path_default=os.path.join(tools_prefix,'lib')  python_lib_path_default=os.path.join(tools_prefix,'lib')
129  python_libs_default=["python%s.%s"%(sys.version_info[0],sys.version_info[1])]  python_lib_default="python%s.%s"%(sys.version_info[0],sys.version_info[1])
130    
131  #==========================================================================  #==========================================================================
132  #  #
133  #    boost installation:  #    boost installation:
134  #  #
135  boost_path_default=os.path.join(tools_prefix,'include')  boost_path_default=os.path.join(tools_prefix,'include')
136  boost_libs_path_default=os.path.join(tools_prefix,'lib')  boost_lib_path_default=os.path.join(tools_prefix,'lib')
137  boost_libs_default=['boost_python']  boost_lib_default=['boost_python']
138  #==========================================================================  #==========================================================================
139  #  #
140  #    check if netCDF is installed on the system:  #    check if netCDF is installed on the system:
# Line 166  opts.AddOptions( Line 170  opts.AddOptions(
170    ('libinstall', 'where the esys libraries will be installed',           dir_libraries),    ('libinstall', 'where the esys libraries will be installed',           dir_libraries),
171    ('pyinstall', 'where the esys python modules will be installed',       dir_packages),    ('pyinstall', 'where the esys python modules will be installed',       dir_packages),
172    ('exinstall', 'where the esys examples will be installed',             dir_examples),    ('exinstall', 'where the esys examples will be installed',             dir_examples),
173      ('sys_libinstall', 'where the system esys libraries will be installed',       sys_dir_libraries),
174      ('sys_pyinstall', 'where the system esys python modules will be installed',   sys_dir_packages),
175      ('sys_exinstall', 'where the system esys examples will be installed',         sys_dir_examples),
176    ('src_zipfile', 'the source zip file will be installed.',              Dir('#.').abspath+"/release/escript_src.zip"),    ('src_zipfile', 'the source zip file will be installed.',              Dir('#.').abspath+"/release/escript_src.zip"),
177    ('test_zipfile', 'the test zip file will be installed.',               Dir('#.').abspath+"/release/escript_tests.zip"),    ('test_zipfile', 'the test zip file will be installed.',               Dir('#.').abspath+"/release/escript_tests.zip"),
178    ('src_tarfile', 'the source tar file will be installed.',              Dir('#.').abspath+"/release/escript_src.tar.gz"),    ('src_tarfile', 'the source tar file will be installed.',              Dir('#.').abspath+"/release/escript_src.tar.gz"),
# Line 216  opts.AddOptions( Line 223  opts.AddOptions(
223    ('netCDF_libs', 'netCDF C++ libraries to link with', netCDF_libs_default),    ('netCDF_libs', 'netCDF C++ libraries to link with', netCDF_libs_default),
224  # Python  # Python
225  # locations of include files for python  # locations of include files for python
226    # FIXME: python_path should be python_inc_path and the same for boost etc.
227    PathOption('python_path', 'Path to Python includes', python_path_default),    PathOption('python_path', 'Path to Python includes', python_path_default),
228    PathOption('python_lib_path', 'Path to Python libs', python_lib_path_default),    PathOption('python_lib_path', 'Path to Python libs', python_lib_path_default),
229    ('python_libs', 'Python libraries to link with', python_libs_default),    ('python_lib', 'Python libraries to link with', python_lib_default),
230      ('python_cmd', 'Python command', 'python'),
231  # Boost  # Boost
232    PathOption('boost_path', 'Path to Boost includes', boost_path_default),    PathOption('boost_path', 'Path to Boost includes', boost_path_default),
233    PathOption('boost_libs_path', 'Path to Boost libs', boost_libs_path_default),    PathOption('boost_lib_path', 'Path to Boost libs', boost_lib_path_default),
234    ('boost_libs', 'Boost libraries to link with', boost_libs_default),    ('boost_lib', 'Boost libraries to link with', boost_lib_default),
235  # Doc building  # Doc building
236  #  PathOption('doxygen_path', 'Path to Doxygen executable', None),  #  PathOption('doxygen_path', 'Path to Doxygen executable', None),
237  #  PathOption('epydoc_path', 'Path to Epydoc executable', None),  #  PathOption('epydoc_path', 'Path to Epydoc executable', None),
# Line 243  opts.AddOptions( Line 252  opts.AddOptions(
252  #   This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms)  #   This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms)
253  #   FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix  #   FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
254  #  #
 IS_WINDOWS_PLATFORM = (os.name== "nt")  
255    
256  if IS_WINDOWS_PLATFORM:  if IS_WINDOWS_PLATFORM:
257        env = Environment(tools = ['default', 'msvc'], options = opts)        env = Environment(tools = ['default', 'msvc'], options = opts)
# Line 261  Help(opts.GenerateHelpText(env)) Line 269  Help(opts.GenerateHelpText(env))
269  #     Initialise Scons Build Environment  #     Initialise Scons Build Environment
270  #     check for user environment variables we are interested in  #     check for user environment variables we are interested in
271  try:  try:
272     python_path = os.environ['PYTHONPATH']     tmp = os.environ['PYTHONPATH']
273     env['ENV']['PYTHONPATH'] = python_path     env['ENV']['PYTHONPATH'] = tmp
274  except KeyError:  except KeyError:
275     python_path = ''     pass
276    
277    env.PrependENVPath('PYTHONPATH', source_root)
278    
279  try:  try:
280     omp_num_threads = os.environ['OMP_NUM_THREADS']     omp_num_threads = os.environ['OMP_NUM_THREADS']
281  except KeyError:  except KeyError:
282     omp_num_threads = 1     omp_num_threads = 1
283    
284  env['ENV']['OMP_NUM_THREADS'] = omp_num_threads  env['ENV']['OMP_NUM_THREADS'] = omp_num_threads
285    
286  try:  try:
# Line 279  except KeyError: Line 290  except KeyError:
290     pass     pass
291    
292  try:  try:
293     path = os.environ['PATH']     tmp = os.environ['PATH']
294     env['ENV']['PATH'] = path     env['ENV']['PATH'] = tmp
295  except KeyError:  except KeyError:
296     path = ''     pass
297    
298  try:  try:
299     ld_library_path = os.environ['LD_LIBRARY_PATH']     tmp = os.environ['LD_LIBRARY_PATH']
300     env['ENV']['LD_LIBRARY_PATH'] = ld_library_path     env['ENV']['LD_LIBRARY_PATH'] = tmp
301  except KeyError:  except KeyError:
302     ld_library_path = ''     pass
303  #==========================================================================  #==========================================================================
304  #  #
305  #    Add some customer builders  #    Add some customer builders
# Line 295  except KeyError: Line 307  except KeyError:
307  py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)  py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
308  env.Append(BUILDERS = {'PyCompile' : py_builder});  env.Append(BUILDERS = {'PyCompile' : py_builder});
309    
310  # TODO: use the inbuilt scons suffix variable.  runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed',
311  if IS_WINDOWS_PLATFORM:                                src_suffix=env['PROGSUFFIX'], single_source=True)
312     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)  
 else:  
    runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)  
313  env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});  env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
314    
315  runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)  runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
# Line 315  try: Line 325  try:
325     libinstall = env['libinstall']     libinstall = env['libinstall']
326     env.Append(LIBPATH = [libinstall,]) # Adds -L for building of libescript.so libfinley.so escriptcpp.so finleycpp.so     env.Append(LIBPATH = [libinstall,]) # Adds -L for building of libescript.so libfinley.so escriptcpp.so finleycpp.so
327     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
328     if env['PLATFORM'] == "win32":     if IS_WINDOWS_PLATFORM :
329        env.PrependENVPath('PATH', libinstall)        env.PrependENVPath('PATH', libinstall)
       env.PrependENVPath('PATH', env['boost_libs_path'])  
330  except KeyError:  except KeyError:
331     libinstall = None     libinstall = None
332  try:  try:
333     pyinstall = env['pyinstall'] # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc     pyinstall = env['pyinstall'] # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
    env.PrependENVPath('PYTHONPATH', env['pyinstall'])  
334  except KeyError:  except KeyError:
335     pyinstall = None     pyinstall = None
336  try:  try:
# Line 330  try: Line 338  try:
338  except KeyError:  except KeyError:
339     exinstall = None     exinstall = None
340  try:  try:
341       sys_libinstall = env['sys_libinstall']
342    except KeyError:
343       sys_libinstall = None
344    try:
345       sys_pyinstall = env['sys_pyinstall']
346    except KeyError:
347       sys_pyinstall = None
348    try:
349       sys_exinstall = env['sys_exinstall']
350    except KeyError:
351       sys_exinstall = None
352    try:
353     dodebug = env['dodebug']     dodebug = env['dodebug']
354  except KeyError:  except KeyError:
355     dodebug = None     dodebug = None
# Line 343  try: Line 363  try:
363  except KeyError:  except KeyError:
364     pass     pass
365    
366    
367  if dodebug:  if dodebug:
368    if useMPI:    if useMPI:
369      try:      try:
# Line 523  except KeyError: Line 544  except KeyError:
544     useNetCDF = 'yes'     useNetCDF = 'yes'
545     pass     pass
546    
 if not useNetCDF == 'yes':  
    print "Warning: Installation is not configured with netCDF. Some I/O function may not be available."  
     
547  if useNetCDF == 'yes':  if useNetCDF == 'yes':
548     try:     try:
549          netCDF_libs = env['netCDF_libs']
550       except KeyError:
551          pass
552    
553       env.Append(LIBS = netCDF_libs)
554       env.Append(CPPDEFINES = [ 'USE_NETCDF' ])
555       try:
556        includes = env['netCDF_path']        includes = env['netCDF_path']
557        env.Append(CPPPATH = [includes,])        env.Append(CPPPATH = [includes,])
558     except KeyError:     except KeyError:
# Line 535  if useNetCDF == 'yes': Line 560  if useNetCDF == 'yes':
560    
561     try:     try:
562        lib_path = env['netCDF_lib_path']        lib_path = env['netCDF_lib_path']
       if IS_WINDOWS_PLATFORM: env['ENV']['PATH']+=";"+lib_path  
563        env.Append(LIBPATH = [ lib_path, ])        env.Append(LIBPATH = [ lib_path, ])
564          if IS_WINDOWS_PLATFORM :
565             env.PrependENVPath('PATH', lib_path)
566     except KeyError:     except KeyError:
567        pass        pass
   
    try:  
       netCDF_libs = env['netCDF_libs']  
    except KeyError:  
       netCDF_libs = [ ]  
568  else:  else:
569       print "Warning: Installation is not configured with netCDF. Some I/O function may not be available."
570     netCDF_libs=[ ]     netCDF_libs=[ ]
571    
572  try:  try:
# Line 553  try: Line 575  try:
575  except KeyError:  except KeyError:
576     pass     pass
577  try:  try:
578     lib_path = env['boost_libs_path']     lib_path = env['boost_lib_path']
579     env.Append(LIBPATH = [lib_path,])     env.Append(LIBPATH = [lib_path,])
580       if IS_WINDOWS_PLATFORM :
581          env.PrependENVPath('PATH', lib_path)
582  except KeyError:  except KeyError:
583     pass     pass
584  try:  try:
585     boost_libs = env['boost_libs']     boost_lib = env['boost_lib']
586  except KeyError:  except KeyError:
587     boost_libs = None     boost_lib = None
588  try:  try:
589     includes = env['python_path']     includes = env['python_path']
590     env.Append(CPPPATH = [includes,])     env.Append(CPPPATH = [includes,])
# Line 572  try: Line 596  try:
596  except KeyError:  except KeyError:
597     pass     pass
598  try:  try:
599     python_libs = env['python_libs']     python_lib = env['python_lib']
600  except KeyError:  except KeyError:
601     python_libs = None     python_lib = None
602  try:  try:
603     doxygen_path = env['doxygen_path']     doxygen_path = env['doxygen_path']
604  except KeyError:  except KeyError:
# Line 645  try: Line 669  try:
669  except KeyError:  except KeyError:
670     api_doxygen = None     api_doxygen = None
671    
672    try:
673       svn_pipe = os.popen("svnversion -n")
674       global_revision = svn_pipe.readlines()
675       svn_pipe.close()
676       global_revision = re.sub("[^0-9]", "", global_revision)
677    except:
678       global_revision = "0"
679    env.Append(CPPDEFINES = "SVN_VERSION="+global_revision[0])
680    
681    # Python install - esys __init__.py
682    init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))
683    
684    # FIXME: exinstall and friends related to examples are not working.
685    build_target = env.Alias('build',[libinstall,incinstall,pyinstall,init_target])
686    
687    env.Default(build_target)
688    
689  # Zipgets  # Zipgets
 env.Default(libinstall)  
 env.Default(incinstall)  
 env.Default(pyinstall)  
 ### env.Default(exinstall) # ksteube this causes dependency error  
690  env.Alias('release_src',[ src_zipfile, src_tarfile ])  env.Alias('release_src',[ src_zipfile, src_tarfile ])
691  env.Alias('release_tests',[ test_zipfile, test_tarfile])  env.Alias('release_tests',[ test_zipfile, test_tarfile])
692  env.Alias('release_examples',[ examples_zipfile, examples_tarfile])  env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
# Line 661  env.Alias('guide_html_index',guide_html_ Line 698  env.Alias('guide_html_index',guide_html_
698  env.Alias('guide_pdf', guide_pdf)  env.Alias('guide_pdf', guide_pdf)
699  env.Alias('docs',[ 'release_examples', 'guide_pdf', api_epydoc, api_doxygen, guide_html_index])  env.Alias('docs',[ 'release_examples', 'guide_pdf', api_epydoc, api_doxygen, guide_html_index])
700  env.Alias('release', ['release_src', 'release_tests', 'docs'])  env.Alias('release', ['release_src', 'release_tests', 'docs'])
701  env.Alias('build_tests')    # target to build all C++ tests  
702  env.Alias('build_py_tests') # target to build all python tests  env.Alias('build_tests',build_target)    # target to build all C++ tests
703    env.Alias('build_py_tests',build_target) # target to build all python tests
704  env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests  env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
705  env.Alias('run_tests', 'build_tests')   # target to run all C++ test  env.Alias('run_tests', 'build_tests')   # target to run all C++ test
706  env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests  env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
707  env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests  env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
708    
 # Python install - esys __init__.py  
 init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))  
 env.Alias(init_target)  
709    
710  # Allow sconscripts to see the env  # Allow sconscripts to see the env
711  Export(["IS_WINDOWS_PLATFORM", "env", "incinstall", "libinstall", "pyinstall", "exinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", "amd_libs", "blas_libs", "netCDF_libs", "useNetCDF",  Export(["env", "incinstall", "libinstall", "pyinstall", "exinstall", "dodebug",
712      "boost_libs", "python_libs", "doxygen_path", "epydoc_path", "papi_libs",          "mkl_libs", "scsl_libs", "umf_libs", "amd_libs", "blas_libs",
713          "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",          "netCDF_libs",
714          "guide_pdf", "guide_html_index", "api_epydoc", "api_doxygen", "useMPI" ])      "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",
715            "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile",
716            "src_tarfile", "examples_tarfile", "examples_zipfile",
717            "guide_pdf", "guide_html_index", "api_epydoc", "api_doxygen", "useMPI"
718            ])
719    
720  # End initialisation section  # End initialisation section
721  # Begin configuration section  # Begin configuration section
# Line 710  env.SConscript(dirs = ['pycad/py_src'], Line 749  env.SConscript(dirs = ['pycad/py_src'],
749  # added by Ben Cumming  # added by Ben Cumming
750  env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)  env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
751  #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)  #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)
752    
753    
754    syslib_install_target = env.installDirectory(sys_libinstall,libinstall)
755    syspy_install_target = env.installDirectory(sys_pyinstall,pyinstall,recursive=True)
756    
757    install_target = env.Alias("install", env.Flatten([syslib_install_target, syspy_install_target]) )

Legend:
Removed from v.1232  
changed lines
  Added in v.1250

  ViewVC Help
Powered by ViewVC 1.1.26