/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 3814 by caltinay, Thu Feb 9 00:11:08 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 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 766  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 849  install_all_list += ['install_finley'] Line 908  install_all_list += ['install_finley']
908  install_all_list += ['install_ripley']  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 882  if not IS_WINDOWS: Line 941  if not IS_WINDOWS:
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.3814  
changed lines
  Added in v.3851

  ViewVC Help
Powered by ViewVC 1.1.26