/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 3784 by caltinay, Wed Jan 25 01:31:42 2012 UTC revision 3851 by jfenwick, Wed Feb 29 05:23:30 2012 UTC
# Line 16  EnsurePythonVersion(2,5) Line 16  EnsurePythonVersion(2,5)
16  import sys, os, platform, re  import sys, os, platform, re
17  from distutils import sysconfig  from distutils import sysconfig
18  from site_init import *  from site_init import *
19    import subprocess
20    from subprocess import PIPE, Popen
21    
22  # Version number to check for in options file. Increment when new features are  # Version number to check for in options file. Increment when new features are
23  # added or existing options changed.  # added or existing options changed.
# Line 126  vars.AddVariables( Line 128  vars.AddVariables(
128    ('sys_libs', 'Extra libraries to link with', []),    ('sys_libs', 'Extra libraries to link with', []),
129    ('escript_opts_version', 'Version of options file (do not specify on command line)'),    ('escript_opts_version', 'Version of options file (do not specify on command line)'),
130    ('SVN_VERSION', 'Do not use from options file', -2),    ('SVN_VERSION', 'Do not use from options file', -2),
131      ('pythoncmd', 'which python to compile with','python'),
132  )  )
133    
134  ##################### Create environment and help text #######################  ##################### Create environment and help text #######################
# Line 209  if cc_name == 'icc': Line 212  if cc_name == 'icc':
212      cc_optim    = "-O3 -ftz -IPF_ftlacc- -IPF_fma -fno-alias -ip"      cc_optim    = "-O3 -ftz -IPF_ftlacc- -IPF_fma -fno-alias -ip"
213      cc_debug    = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"      cc_debug    = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
214      omp_flags   = "-openmp -openmp_report0"      omp_flags   = "-openmp -openmp_report0"
215      omp_ldflags = "-openmp -openmp_report0 -lguide -lpthread"      omp_ldflags = "-openmp -openmp_report0 -lpthread"
216      fatalwarning = "-Werror"      fatalwarning = "-Werror"
217  elif cc_name[:3] == 'gcc':  elif cc_name[:3] == 'gcc':
218      # GNU C on any system      # GNU C on any system
# Line 352  except KeyError: Line 355  except KeyError:
355    
356  ######################## Add some custom builders ############################  ######################## Add some custom builders ############################
357    
358  py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)  if env['pythoncmd']=='python':
359        py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
360    else:
361        py_builder = Builder(action = "scripts/testcomp.py $SOURCE $TARGET", suffix = '.pyc', src_suffix = '.py', single_source=True)
362  env.Append(BUILDERS = {'PyCompile' : py_builder});  env.Append(BUILDERS = {'PyCompile' : py_builder});
363    
364  runUnitTest_builder = Builder(action = runUnitTest, suffix = '.passed', src_suffix=env['PROGSUFFIX'], single_source=True)  runUnitTest_builder = Builder(action = runUnitTest, suffix = '.passed', src_suffix=env['PROGSUFFIX'], single_source=True)
# Line 404  if IS_WINDOWS: Line 410  if IS_WINDOWS:
410  else:  else:
411      python_libs=['python'+sysconfig.get_python_version()]      python_libs=['python'+sysconfig.get_python_version()]
412    
413    #if we want to use a python other than the one scons is running
414    if env['pythoncmd']!='python':
415       py3scons=False   # Is scons running on python3?
416       initstring='from __future__ import print_function;from distutils import sysconfig;'
417       if IS_WINDOWS:
418          cmd='print("python%s%s"%(sys.version_info[0], sys.version_info[1]))'
419       else:
420          cmd='print("python"+sysconfig.get_python_version())'
421       p=Popen([env['pythoncmd'], '-c', initstring+cmd], stdout=PIPE)
422       python_libs=p.stdout.readline()
423       if type(python_libs)!=str():
424          py3scons=True
425          python_libs=python_libs.encode()
426       p.wait()
427       python_libs=python_libs.strip()
428       # Now we know whether we are using python3 or not
429       p=Popen([env['pythoncmd'], '-c',  initstring+'print(sysconfig.get_python_inc())'], stdout=PIPE)
430       python_inc_path=p.stdout.readline()
431       if py3scons:
432             python_inc_path=python_inc_path.encode()
433       p.wait()  
434       python_inc_path=python_inc_path.strip()
435       if IS_WINDOWS:
436            cmd="os.path.join(sysconfig.get_config_var('prefix'), 'libs')"
437       elif env['PLATFORM']=='darwin':
438            cmd="sysconfig.get_config_var(\"LIBPL\")"
439       else:
440            cmd="sysconfig.get_config_var(\"LIBDIR\")"
441    
442       p=Popen([env['pythoncmd'], '-c', initstring+'print('+cmd+')'], stdout=PIPE)
443       python_lib_path=p.stdout.readline()
444       if py3scons:
445          python_lib_path=python_lib_path.decode()
446       p.wait()
447       python_lib_path=python_lib_path.strip()
448    
449    
450    
451    
452  if sysheaderopt == '':  if sysheaderopt == '':
453      conf.env.AppendUnique(CPPPATH = [python_inc_path])      conf.env.AppendUnique(CPPPATH = [python_inc_path])
454  else:  else:
# Line 450  env.PrependENVPath(LD_LIBRARY_PATH_KEY, Line 495  env.PrependENVPath(LD_LIBRARY_PATH_KEY,
495    
496  ######## numpy (required)  ######## numpy (required)
497    
498  try:  if env['pythoncmd']=='python':
499      from numpy import identity      try:
500  except ImportError:        from numpy import identity
501      print("Cannot import numpy, you need to set your PYTHONPATH and probably %s"%LD_LIBRARY_PATH_KEY)      except ImportError:
502      Exit(1)        print("Cannot import numpy, you need to set your PYTHONPATH and probably %s"%LD_LIBRARY_PATH_KEY)
503          Exit(1)
504    else:
505        p=subprocess.call([env['pythoncmd'],'-c','import numpy'])
506        if p!=0:
507          print("Cannot import numpy, you need to set your PYTHONPATH and probably %s"%LD_LIBRARY_PATH_KEY)
508          Exit(1)
509    
510  ######## CppUnit (required for tests)  ######## CppUnit (required for tests)
511    
# Line 697  if env['numpy_h']: Line 748  if env['numpy_h']:
748      print("   numpy headers:  FOUND")      print("   numpy headers:  FOUND")
749  else:  else:
750      print("   numpy headers:  NOT FOUND")      print("   numpy headers:  NOT FOUND")
751    print("   vsl_random:  %s"%env['vsl_random'])
752            
753  if ((fatalwarning != '') and (env['werror'])):  if ((fatalwarning != '') and (env['werror'])):
754      print("  Treating warnings as errors")      print("  Treating warnings as errors")
# Line 734  env.SConscript(dirs = ['esysUtils/src'], Line 786  env.SConscript(dirs = ['esysUtils/src'],
786  env.SConscript(dirs = ['pasowrap/src'], variant_dir='$BUILD_DIR/$PLATFORM/pasowrap', duplicate=0)  env.SConscript(dirs = ['pasowrap/src'], variant_dir='$BUILD_DIR/$PLATFORM/pasowrap', duplicate=0)
787  env.SConscript(dirs = ['dudley/src'], variant_dir='$BUILD_DIR/$PLATFORM/dudley', duplicate=0)  env.SConscript(dirs = ['dudley/src'], variant_dir='$BUILD_DIR/$PLATFORM/dudley', duplicate=0)
788  env.SConscript(dirs = ['finley/src'], variant_dir='$BUILD_DIR/$PLATFORM/finley', duplicate=0)  env.SConscript(dirs = ['finley/src'], variant_dir='$BUILD_DIR/$PLATFORM/finley', duplicate=0)
789    env.SConscript(dirs = ['ripley/src'], variant_dir='$BUILD_DIR/$PLATFORM/ripley', duplicate=0)
790  env.SConscript(dirs = ['modellib/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/modellib', duplicate=0)  env.SConscript(dirs = ['modellib/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/modellib', duplicate=0)
791  env.SConscript(dirs = ['doc'], variant_dir='$BUILD_DIR/$PLATFORM/doc', duplicate=0)  env.SConscript(dirs = ['doc'], variant_dir='$BUILD_DIR/$PLATFORM/doc', duplicate=0)
792  env.SConscript(dirs = ['pyvisi/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/pyvisi', duplicate=0)  env.SConscript(dirs = ['pyvisi/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/pyvisi', duplicate=0)
# Line 765  buildvars.write("svn_revision="+str(glob Line 818  buildvars.write("svn_revision="+str(glob
818  buildvars.write("prefix="+prefix+"\n")  buildvars.write("prefix="+prefix+"\n")
819  buildvars.write("cc="+env['CC']+"\n")  buildvars.write("cc="+env['CC']+"\n")
820  buildvars.write("cxx="+env['CXX']+"\n")  buildvars.write("cxx="+env['CXX']+"\n")
821  buildvars.write("python="+sys.executable+"\n")  if env['pythoncmd']=='python':
822  buildvars.write("python_version="+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+"\n")      buildvars.write("python="+sys.executable+"\n")
823        buildvars.write("python_version="+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+"\n")
824    else:
825        buildvars.write("python="+env['pythoncmd']+"\n")
826        p=Popen([env['pythoncmd'], '-c', 'from __future__import print_function;import sys;print(str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])'], stdout=PIPE)
827        verstring=p.stdout.readline().strip()
828        p.wait()
829        buildvars.write("python version="+verstring+"\n")
830  buildvars.write("boost_inc_path="+boost_inc_path+"\n")  buildvars.write("boost_inc_path="+boost_inc_path+"\n")
831  buildvars.write("boost_lib_path="+boost_lib_path+"\n")  buildvars.write("boost_lib_path="+boost_lib_path+"\n")
832  buildvars.write("boost_version="+boostversion+"\n")  buildvars.write("boost_version="+boostversion+"\n")
# Line 813  env.Alias('install_dudley', ['build_dudl Line 873  env.Alias('install_dudley', ['build_dudl
873  env.Alias('build_finley', ['install_finley_headers', 'build_finley_lib', 'build_finleycpp_lib'])  env.Alias('build_finley', ['install_finley_headers', 'build_finley_lib', 'build_finleycpp_lib'])
874  env.Alias('install_finley', ['build_finley', 'install_finley_lib', 'install_finleycpp_lib', 'install_finley_py'])  env.Alias('install_finley', ['build_finley', 'install_finley_lib', 'install_finleycpp_lib', 'install_finley_py'])
875    
876    env.Alias('build_ripley', ['install_ripley_headers', 'build_ripley_lib', 'build_ripleycpp_lib'])
877    env.Alias('install_ripley', ['build_ripley', 'install_ripley_lib', 'install_ripleycpp_lib', 'install_ripley_py'])
878    
879  env.Alias('build_weipa', ['install_weipa_headers', 'build_weipa_lib', 'build_weipacpp_lib'])  env.Alias('build_weipa', ['install_weipa_headers', 'build_weipa_lib', 'build_weipacpp_lib'])
880  env.Alias('install_weipa', ['build_weipa', 'install_weipa_lib', 'install_weipacpp_lib', 'install_weipa_py'])  env.Alias('install_weipa', ['build_weipa', 'install_weipa_lib', 'install_weipacpp_lib', 'install_weipa_py'])
881    
# Line 827  build_all_list += ['build_escript'] Line 890  build_all_list += ['build_escript']
890  build_all_list += ['build_pasowrap']  build_all_list += ['build_pasowrap']
891  build_all_list += ['build_dudley']  build_all_list += ['build_dudley']
892  build_all_list += ['build_finley']  build_all_list += ['build_finley']
893    build_all_list += ['build_ripley']
894  build_all_list += ['build_weipa']  build_all_list += ['build_weipa']
895  if not IS_WINDOWS: build_all_list += ['build_escriptreader']  if not IS_WINDOWS: build_all_list += ['build_escriptreader']
896  if env['usempi']:   build_all_list += ['build_pythonMPI']  if env['usempi']:   build_all_list += ['build_pythonMPI']
# Line 841  install_all_list += ['install_escript'] Line 905  install_all_list += ['install_escript']
905  install_all_list += ['install_pasowrap']  install_all_list += ['install_pasowrap']
906  install_all_list += ['install_dudley']  install_all_list += ['install_dudley']
907  install_all_list += ['install_finley']  install_all_list += ['install_finley']
908    install_all_list += ['install_ripley']
909  install_all_list += ['install_weipa']  install_all_list += ['install_weipa']
910  if not IS_WINDOWS: install_all_list += ['install_escriptreader']  if not IS_WINDOWS: install_all_list += ['install_escriptreader']
911  install_all_list += ['install_pyvisi_py']  #install_all_list += ['install_pyvisi_py']
912  install_all_list += ['install_modellib_py']  install_all_list += ['install_modellib_py']
913  install_all_list += ['install_pycad_py']  install_all_list += ['install_pycad_py']
914  if env['usempi']:   install_all_list += ['install_pythonMPI']  if env['usempi']:   install_all_list += ['install_pythonMPI']
# Line 872  env.Alias('release_prep', ['docs', 'inst Line 937  env.Alias('release_prep', ['docs', 'inst
937  if not IS_WINDOWS:  if not IS_WINDOWS:
938      try:      try:
939          utest=open('utest.sh','w')          utest=open('utest.sh','w')
940          utest.write(GroupTest.makeHeader(env['PLATFORM']))          utest.write(GroupTest.makeHeader(env['PLATFORM'], prefix))
941          for tests in TestGroups:          for tests in TestGroups:
942              utest.write(tests.makeString())              utest.write(tests.makeString())
943          utest.close()          utest.close()
944          Execute(Chmod('utest.sh', 0755))          Execute(Chmod('utest.sh', 0o755))
945          print("Generated utest.sh.")          print("Generated utest.sh.")
946      except IOError:      except IOError:
947          print("Error attempting to write unittests file.")          print("Error attempting to write unittests file.")

Legend:
Removed from v.3784  
changed lines
  Added in v.3851

  ViewVC Help
Powered by ViewVC 1.1.26