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 ####################### |
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']) |
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) |
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]) |
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 conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']): |
479 |
conf.env.Append(CPPDEFINES = ['HAVE_NUMPY_H']) |
# conf.env.Append(CPPDEFINES = ['HAVE_NUMPY_H']) |
480 |
conf.env['numpy_h']=True |
# conf.env['numpy_h']=True |
481 |
else: |
#else: |
482 |
conf.env['numpy_h']=False |
# conf.env['numpy_h']=False |
483 |
|
|
484 |
|
|
485 |
|
# This is until we can work out how to make the checks in python 3 |
486 |
|
conf.env['numpy_h']=False |
487 |
|
|
488 |
|
|
489 |
# Commit changes to environment |
# Commit changes to environment |
490 |
env = conf.Finish() |
env = conf.Finish() |
807 |
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) |
808 |
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) |
809 |
|
|
810 |
|
|
811 |
######################## Populate the buildvars file ######################### |
######################## Populate the buildvars file ######################### |
812 |
|
|
813 |
# remove obsolete file |
# remove obsolete file |
827 |
pass |
pass |
828 |
boosthpp.close() |
boosthpp.close() |
829 |
|
|
830 |
|
|
831 |
buildvars=open(os.path.join(env['libinstall'], 'buildvars'), 'w') |
buildvars=open(os.path.join(env['libinstall'], 'buildvars'), 'w') |
832 |
buildvars.write("svn_revision="+str(global_revision)+"\n") |
buildvars.write("svn_revision="+str(global_revision)+"\n") |
833 |
buildvars.write("prefix="+prefix+"\n") |
buildvars.write("prefix="+prefix+"\n") |
838 |
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") |
839 |
else: |
else: |
840 |
buildvars.write("python="+env['pythoncmd']+"\n") |
buildvars.write("python="+env['pythoncmd']+"\n") |
841 |
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) |
842 |
verstring=p.stdout.readline().strip() |
verstring=p.stdout.readline().strip() |
843 |
p.wait() |
p.wait() |
844 |
buildvars.write("python version="+verstring+"\n") |
buildvars.write("python_version="+verstring+"\n") |
845 |
buildvars.write("boost_inc_path="+boost_inc_path+"\n") |
buildvars.write("boost_inc_path="+boost_inc_path+"\n") |
846 |
buildvars.write("boost_lib_path="+boost_lib_path+"\n") |
buildvars.write("boost_lib_path="+boost_lib_path+"\n") |
847 |
buildvars.write("boost_version="+boostversion+"\n") |
buildvars.write("boost_version="+boostversion+"\n") |
881 |
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']) |
882 |
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']) |
883 |
|
|
|
|
|
884 |
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']) |
885 |
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']) |
886 |
|
|