/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 3851 by jfenwick, Wed Feb 29 05:23:30 2012 UTC revision 3911 by jfenwick, Thu Jun 14 01:01:03 2012 UTC
# Line 1  Line 1 
1  ########################################################  ########################################################
2  #  #
3  # Copyright (c) 2003-2010 by University of Queensland  # Copyright (c) 2003-2012 by University of Queensland
4  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
5  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
6  #  #
# Line 129  vars.AddVariables( Line 129  vars.AddVariables(
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'),    ('pythoncmd', 'which python to compile with','python'),
132      ('usepython3', 'Is this a python3 build? (experimental)', False),
133      ('pythonlibname', 'Name of the python library to link. (This is found automatically for python2.X.)', ''),
134  )  )
135    
136  ##################### Create environment and help text #######################  ##################### Create environment and help text #######################
# Line 247  if env['cc_extra']  != '': env.Append(CF Line 249  if env['cc_extra']  != '': env.Append(CF
249  if env['cxx_extra'] != '': env.Append(CXXFLAGS = env['cxx_extra'])  if env['cxx_extra'] != '': env.Append(CXXFLAGS = env['cxx_extra'])
250  if env['ld_extra']  != '': env.Append(LINKFLAGS = env['ld_extra'])  if env['ld_extra']  != '': env.Append(LINKFLAGS = env['ld_extra'])
251    
252    if env['usepython3']:
253        env.Append(CPPDEFINES=['ESPYTHON3'])
254    
255  # set up the autolazy values  # set up the autolazy values
256  if env['forcelazy'] == 'on':  if env['forcelazy'] == 'on':
257      env.Append(CPPDEFINES=['FAUTOLAZYON'])      env.Append(CPPDEFINES=['FAUTOLAZYON'])
# Line 358  except KeyError: Line 363  except KeyError:
363  if env['pythoncmd']=='python':  if env['pythoncmd']=='python':
364      py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)      py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
365  else:  else:
366      py_builder = Builder(action = "scripts/testcomp.py $SOURCE $TARGET", suffix = '.pyc', src_suffix = '.py', single_source=True)      py_builder = Builder(action = env['pythoncmd']+" scripts/py_comp.py $SOURCE $TARGET", suffix = '.pyc', src_suffix = '.py', single_source=True)
367  env.Append(BUILDERS = {'PyCompile' : py_builder});  env.Append(BUILDERS = {'PyCompile' : py_builder});
368    
369  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 397  if conf.CheckFunc('gethostname'): Line 402  if conf.CheckFunc('gethostname'):
402    
403  ######## Python headers & library (required)  ######## Python headers & library (required)
404    
405  python_inc_path=sysconfig.get_python_inc()  # Use the python scons is running
406  if IS_WINDOWS:  if env['pythoncmd']=='python':
407      python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs')      python_inc_path=sysconfig.get_python_inc()
408  elif env['PLATFORM']=='darwin':      if IS_WINDOWS:
409      python_lib_path=sysconfig.get_config_var('LIBPL')          python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs')
410  else:      elif env['PLATFORM']=='darwin':
411      python_lib_path=sysconfig.get_config_var('LIBDIR')          python_lib_path=sysconfig.get_config_var('LIBPL')
412  #python_libs=[sysconfig.get_config_var('LDLIBRARY')] # only on linux      else:
413  if IS_WINDOWS:          python_lib_path=sysconfig.get_config_var('LIBDIR')
414      python_libs=['python%s%s'%(sys.version_info[0], sys.version_info[1])]  
415  else:      #python_libs=[sysconfig.get_config_var('LDLIBRARY')] # only on linux
416      python_libs=['python'+sysconfig.get_python_version()]      if IS_WINDOWS:
417            python_libs=['python%s%s'%(sys.version_info[0], sys.version_info[1])]
418        else:
419            python_libs=['python'+sysconfig.get_python_version()]
420    
421  #if we want to use a python other than the one scons is running  #if we want to use a python other than the one scons is running
422  if env['pythoncmd']!='python':  else:
423     py3scons=False   # Is scons running on python3?      initstring='from __future__ import print_function;from distutils import sysconfig;'
424     initstring='from __future__ import print_function;from distutils import sysconfig;'      if env['pythonlibname']!='':
425     if IS_WINDOWS:          python_libs=env['pythonlibname']
426        cmd='print("python%s%s"%(sys.version_info[0], sys.version_info[1]))'      else:   # work it out by calling python    
427     else:          if IS_WINDOWS:
428        cmd='print("python"+sysconfig.get_python_version())'              cmd='print("python%s%s"%(sys.version_info[0], sys.version_info[1]))'
429     p=Popen([env['pythoncmd'], '-c', initstring+cmd], stdout=PIPE)          else:
430     python_libs=p.stdout.readline()              cmd='print("python"+sysconfig.get_python_version())'
431     if type(python_libs)!=str():          p=Popen([env['pythoncmd'], '-c', initstring+cmd], stdout=PIPE)
432        py3scons=True          python_libs=p.stdout.readline()
433        python_libs=python_libs.encode()          if env['usepython3']:       # This is to convert unicode str into py2 string
434     p.wait()              python_libs=python_libs.encode() # If scons runs on py3 then this must be rethought
435     python_libs=python_libs.strip()          p.wait()
436     # Now we know whether we are using python3 or not          python_libs=python_libs.strip()
437     p=Popen([env['pythoncmd'], '-c',  initstring+'print(sysconfig.get_python_inc())'], stdout=PIPE)  
438     python_inc_path=p.stdout.readline()    
439     if py3scons:      # Now we know whether we are using python3 or not
440        p=Popen([env['pythoncmd'], '-c',  initstring+'print(sysconfig.get_python_inc())'], stdout=PIPE)
441        python_inc_path=p.stdout.readline()
442        if env['usepython3']:
443           python_inc_path=python_inc_path.encode()           python_inc_path=python_inc_path.encode()
444     p.wait()        p.wait()  
445     python_inc_path=python_inc_path.strip()      python_inc_path=python_inc_path.strip()
446     if IS_WINDOWS:      if IS_WINDOWS:
447          cmd="os.path.join(sysconfig.get_config_var('prefix'), 'libs')"          cmd="os.path.join(sysconfig.get_config_var('prefix'), 'libs')"
448     elif env['PLATFORM']=='darwin':      elif env['PLATFORM']=='darwin':
449          cmd="sysconfig.get_config_var(\"LIBPL\")"          cmd="sysconfig.get_config_var(\"LIBPL\")"
450     else:      else:
451          cmd="sysconfig.get_config_var(\"LIBDIR\")"          cmd="sysconfig.get_config_var(\"LIBDIR\")"
452    
453     p=Popen([env['pythoncmd'], '-c', initstring+'print('+cmd+')'], stdout=PIPE)      p=Popen([env['pythoncmd'], '-c', initstring+'print('+cmd+')'], stdout=PIPE)
454     python_lib_path=p.stdout.readline()      python_lib_path=p.stdout.readline()
455     if py3scons:      if env['usepython3']:
456        python_lib_path=python_lib_path.decode()          python_lib_path=python_lib_path.decode()
457     p.wait()      p.wait()
458     python_lib_path=python_lib_path.strip()      python_lib_path=python_lib_path.strip()
   
   
   
459    
460  if sysheaderopt == '':  if sysheaderopt == '':
461      conf.env.AppendUnique(CPPPATH = [python_inc_path])      conf.env.AppendUnique(CPPPATH = [python_inc_path])
# Line 466  if not conf.CheckFunc('Py_Exit'): Line 474  if not conf.CheckFunc('Py_Exit'):
474      print("Cannot find python library method Py_Main (tried %s in directory %s)" % (python_libs, python_lib_path))      print("Cannot find python library method Py_Main (tried %s in directory %s)" % (python_libs, python_lib_path))
475      Exit(1)      Exit(1)
476    
477  # reuse conf to check for numpy header (optional)  ## reuse conf to check for numpy header (optional)
478  if conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']):  if env['usepython3']:
479      conf.env.Append(CPPDEFINES = ['HAVE_NUMPY_H'])      # FIXME: This is until we can work out how to make the checks in python 3
     conf.env['numpy_h']=True  
 else:  
480      conf.env['numpy_h']=False      conf.env['numpy_h']=False
481    else:
482        if conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']):
483            conf.env.Append(CPPDEFINES = ['HAVE_NUMPY_H'])
484            conf.env['numpy_h']=True
485        else:
486            conf.env['numpy_h']=False
487    
488  # Commit changes to environment  # Commit changes to environment
489  env = conf.Finish()  env = conf.Finish()
# Line 794  env.SConscript(dirs = ['pycad/py_src'], Line 806  env.SConscript(dirs = ['pycad/py_src'],
806  env.SConscript(dirs = ['pythonMPI/src'], variant_dir='$BUILD_DIR/$PLATFORM/pythonMPI', duplicate=0)  env.SConscript(dirs = ['pythonMPI/src'], variant_dir='$BUILD_DIR/$PLATFORM/pythonMPI', duplicate=0)
807  env.SConscript(dirs = ['paso/profiling'], variant_dir='$BUILD_DIR/$PLATFORM/paso/profiling', duplicate=0)  env.SConscript(dirs = ['paso/profiling'], variant_dir='$BUILD_DIR/$PLATFORM/paso/profiling', duplicate=0)
808    
809    
810  ######################## Populate the buildvars file #########################  ######################## Populate the buildvars file #########################
811    
812  # remove obsolete file  # remove obsolete file
# Line 813  except StopIteration: Line 826  except StopIteration:
826      pass      pass
827  boosthpp.close()  boosthpp.close()
828    
829    
830  buildvars=open(os.path.join(env['libinstall'], 'buildvars'), 'w')  buildvars=open(os.path.join(env['libinstall'], 'buildvars'), 'w')
831  buildvars.write("svn_revision="+str(global_revision)+"\n")  buildvars.write("svn_revision="+str(global_revision)+"\n")
832  buildvars.write("prefix="+prefix+"\n")  buildvars.write("prefix="+prefix+"\n")
# Line 823  if env['pythoncmd']=='python': Line 837  if env['pythoncmd']=='python':
837      buildvars.write("python_version="+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+"\n")      buildvars.write("python_version="+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+"\n")
838  else:  else:
839      buildvars.write("python="+env['pythoncmd']+"\n")      buildvars.write("python="+env['pythoncmd']+"\n")
840      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)      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)
841      verstring=p.stdout.readline().strip()      verstring=p.stdout.readline().strip()
842      p.wait()      p.wait()
843      buildvars.write("python version="+verstring+"\n")      buildvars.write("python_version="+verstring+"\n")
844  buildvars.write("boost_inc_path="+boost_inc_path+"\n")  buildvars.write("boost_inc_path="+boost_inc_path+"\n")
845  buildvars.write("boost_lib_path="+boost_lib_path+"\n")  buildvars.write("boost_lib_path="+boost_lib_path+"\n")
846  buildvars.write("boost_version="+boostversion+"\n")  buildvars.write("boost_version="+boostversion+"\n")
# Line 866  env.Alias('install_escript', ['build_esc Line 880  env.Alias('install_escript', ['build_esc
880  env.Alias('build_pasowrap', ['install_pasowrap_headers', 'build_pasowrap_lib', 'build_pasowrapcpp_lib'])  env.Alias('build_pasowrap', ['install_pasowrap_headers', 'build_pasowrap_lib', 'build_pasowrapcpp_lib'])
881  env.Alias('install_pasowrap', ['build_pasowrap', 'install_pasowrap_lib', 'install_pasowrapcpp_lib', 'install_pasowrap_py'])  env.Alias('install_pasowrap', ['build_pasowrap', 'install_pasowrap_lib', 'install_pasowrapcpp_lib', 'install_pasowrap_py'])
882    
   
883  env.Alias('build_dudley', ['install_dudley_headers', 'build_dudley_lib', 'build_dudleycpp_lib'])  env.Alias('build_dudley', ['install_dudley_headers', 'build_dudley_lib', 'build_dudleycpp_lib'])
884  env.Alias('install_dudley', ['build_dudley', 'install_dudley_lib', 'install_dudleycpp_lib', 'install_dudley_py'])  env.Alias('install_dudley', ['build_dudley', 'install_dudley_lib', 'install_dudleycpp_lib', 'install_dudley_py'])
885    

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

  ViewVC Help
Powered by ViewVC 1.1.26