diff --git a/Cantera/SConscript b/Cantera/clib/SConscript similarity index 65% rename from Cantera/SConscript rename to Cantera/clib/SConscript index 7c4f8fc67..f4d661794 100644 --- a/Cantera/SConscript +++ b/Cantera/clib/SConscript @@ -3,12 +3,11 @@ from buildutils import * Import('env', 'build') # (subdir, library name, (file extensions)) -libs = [LibOpts('cxx/src', 'ctcxx'), - LibOpts('clib/src', 'clib')] +libs = [LibOpts('src', 'clib')] print os.getcwd() for lib in libs: localenv = env.Clone() - localenv.Library(pjoin('../lib', lib.name), + localenv.Library(pjoin('../../lib', lib.name), source=mglob(localenv, lib.subdir, *lib.extensions)) diff --git a/Cantera/cxx/SConscript b/Cantera/cxx/SConscript new file mode 100644 index 000000000..9631ffae6 --- /dev/null +++ b/Cantera/cxx/SConscript @@ -0,0 +1,13 @@ +from buildutils import * + +Import('env', 'build') + +# (subdir, library name, (file extensions)) +libs = [LibOpts('src', 'ctcxx')] + +print os.getcwd() +for lib in libs: + localenv = env.Clone() + localenv.Library(pjoin('../../lib', lib.name), + source=mglob(localenv, lib.subdir, *lib.extensions)) + diff --git a/Cantera/python/SConscript b/Cantera/python/SConscript new file mode 100644 index 000000000..aedeec6e8 --- /dev/null +++ b/Cantera/python/SConscript @@ -0,0 +1,46 @@ +from buildutils import * +import distutils.sysconfig + +Import('env', 'build') + +localenv = env.Clone() + +def make_ctconf(target, source, env): + text = """ +buildPython = %(BUILD_PYTHON)s +ctversion = %(cantera_version)r +""" % env + + with open(str(target[0]), 'w') as f: + f.write(text) + +conf = localenv.Command('ctconf.py', [], make_ctconf) +gcv = distutils.sysconfig.get_config_var + +localenv.Append(CPPPATH=[gcv('INCLUDEPY')], + SHLINKFLAGS=gcv('LDFLAGS'), + CPPFLAGS=[gcv('BASECFLAGS'), gcv('OPT')]) + +linkLibs = ['clib','oneD','zeroD','equil','kinetics','transport', + 'thermo','ctnumerics','ctmath','tpx', + 'ctspectra','converters','ctbase'] + +if env['use_sundials']: + linkLibs.extend(('sundials_cvodes','sundials_nvecserial')) + +linkLibs.extend(localenv['blas_lapack_libs']) + +if env['build_with_f2c']: + linkLibs.append('ctf2c') +else: + linkLibs.append('gfortran') + +pymodule = localenv.SharedLibrary('Cantera/_cantera', ['src/pycantera.cpp'], + LIBS=linkLibs, + SHLIBPREFIX='', + SHLIBSUFFIX=gcv('SO')) + +pybuild = localenv.Command('built_python', 'Cantera/_cantera.so', + 'cd Cantera/python; python setup.py build; touch built_python') + +localenv.Depends(pybuild, [pymodule, conf]) diff --git a/Cantera/python/setup.py b/Cantera/python/setup.py new file mode 100644 index 000000000..ec58c6842 --- /dev/null +++ b/Cantera/python/setup.py @@ -0,0 +1,36 @@ +import sys +import string +from distutils.core import setup, Extension + +import ctconf + +platform = sys.platform + +# values: +# 0 do nothing +# 1 install only ctml_writer.py +# 2 install full package + +if ctconf.buildPython >= 2: + setup(name="Cantera", + version=ctconf.ctversion, + description="The Cantera Python Interface", + long_description=""" + """, + author="Prof. D. G. Goodwin, Caltech", + author_email="dgoodwin@caltech.edu", + url="http://code.google.com/p/cantera", + package_dir = {'MixMaster':'../../apps/MixMaster'}, + packages = ["","Cantera","Cantera.OneD", + "MixMaster","MixMaster.Units"], + package_data = {'Cantera': ['_cantera.so']}) +elif ctconf.buildPython == 1: + setup(name="Cantera CTI File Processor", + version=ctconf.ctversion, + description="Converts .cti files to CTML", + long_description=""" + """, + author="Prof. D. G. Goodwin, Caltech", + author_email="dgoodwin@caltech.edu", + url="http://www.cantera.org", + py_modules = ["ctml_writer"]) diff --git a/Cantera/python/src/pycantera.cpp b/Cantera/python/src/pycantera.cpp index dc9655c5b..c33c44707 100644 --- a/Cantera/python/src/pycantera.cpp +++ b/Cantera/python/src/pycantera.cpp @@ -33,15 +33,15 @@ #endif #endif -#include "ct.h" -#include "ctxml.h" -#include "ctsurf.h" -#include "ctbdry.h" -#include "ctrpath.h" -#include "ctreactor.h" -#include "ctfunc.h" -#include "ctonedim.h" -#include "ctmultiphase.h" +#include "clib/ct.h" +#include "clib/ctxml.h" +#include "clib/ctsurf.h" +#include "clib/ctbdry.h" +#include "clib/ctrpath.h" +#include "clib/ctreactor.h" +#include "clib/ctfunc.h" +#include "clib/ctonedim.h" +#include "clib/ctmultiphase.h" #include using namespace std; diff --git a/SConstruct b/SConstruct index 59f7f74f4..4d59f3456 100644 --- a/SConstruct +++ b/SConstruct @@ -44,7 +44,7 @@ opts.AddVariables( BoolVariable('enable_tpx', '', True), BoolVariable('with_html_log_files', '', True), EnumVariable('use_sundials', '', 'default', ('default', 'y', 'n')), - ('blas_lapack_libs', '', ''), # '-llapack -lblas' or '-llapack -lf77blas -lcblas -latlas' etc. + ('blas_lapack_libs', '', ''), # 'lapack,blas' or 'lapack,f77blas,cblas,atlas' etc. ('blas_lapack_dir', '', ''), # '/usr/lib/lapack' etc EnumVariable('lapack_names', '', 'lower', ('lower','upper')), BoolVariable('lapack_ftn_trailing_underscore', '', True), @@ -93,6 +93,11 @@ if env['python_package'] in ('full', 'default'): PathVariable('cantera_python_home', 'where to install the python package', None, PathVariable.PathAccept), ) + env['BUILD_PYTHON'] = 3 +elif env['python_package'] == 'minimal': + env['BUILD_PYTHON'] = 1 +else: + env['BUILD_PYTHON'] = 0 # Options that apply only if building the Matlab interface if env['matlab_toolbox'] != 'n': @@ -112,7 +117,8 @@ if env['f90_interface']: if env['use_sundials'] != 'n': opts.AddVariables( EnumVariable('sundials_version' ,'', '2.4', ('2.2','2.3','2.4')), - PathVariable('sundials_include' ,'', '')) + PathVariable('sundials_include' ,'', ''), + PathVariable('sundials_libdir', '', '')) # Extra options for Boost.Thread if env['build_thread_safe']: @@ -211,10 +217,15 @@ env.AlwaysBuild(config_h) if env['blas_lapack_libs'] == '': # External BLAS/LAPACK were not given, so we need to compile them env['BUILD_BLAS_LAPACK'] = True - env['blas_lapack_libs'] = '-lctlapack -lctblas' + env['blas_lapack_libs'] = ['ctlapack', 'ctblas'] +else: + ens['blas_lapack_libs'] = ','.split(env['blas_lapack_libs']) + if env['use_sundials'] == 'y' and env['sundials_include']: env.Append(CPPPATH=env['sundials_include']) +if env['use_sundials'] == 'y' and env['sundials_libdir']: + env.Append(LIBPATH=env['sundials_libdir']) # ********************* # *** Build Cantera *** @@ -229,12 +240,18 @@ for header in mglob(env, 'Cantera/clib/src', 'h'): env.Command('build/include/cantera/clib/%s' % header.name, header, Copy('$TARGET', '$SOURCE')) +env.Command('build/include/cantera/config.h', 'config.h', Copy('$TARGET', '$SOURCE')) build = 'build' env.SConsignFile() env.Append(CPPPATH=[Dir(os.getcwd()), Dir('build/include/cantera/kernel'), - Dir('build/include/cantera')]) + Dir('build/include/cantera'), + Dir('build/include')], + LIBPATH=[Dir('build/lib')], + CCFLAGS=['-fPIC'], + FORTRANFLAGS=['-fPIC'], + F90FLAGS=['-fPIC']) Export('env', 'build') @@ -244,8 +261,13 @@ SConscript('build/ext/SConscript') VariantDir('build/kernel', 'Cantera/src', duplicate=0) SConscript('build/kernel/SConscript') -VariantDir('build/interfaces/', 'Cantera', duplicate=0) -SConscript('build/interfaces/SConscript') +VariantDir('build/interfaces/clib', 'Cantera/clib', duplicate=0) +SConscript('build/interfaces/clib/SConscript') + +VariantDir('build/interfaces/cxx', 'Cantera/cxx', duplicate=0) +SConscript('build/interfaces/cxx/SConscript') VariantDir('build/interfaces/fortran/', 'Cantera/fortran', duplicate=1) SConscript('build/interfaces/fortran/SConscript') + +SConscript('Cantera/python/SConscript') diff --git a/ext/SConscript b/ext/SConscript index a890d24a9..806b7788f 100644 --- a/ext/SConscript +++ b/ext/SConscript @@ -5,10 +5,12 @@ localenv = env.Clone() # (subdir, library name, (file extensions)) libs = [('tpx','tpx',['cpp']), - ('math', 'ctmath', ['cpp','c','f'])] + ] print os.getcwd() if env['build_with_f2c']: + libs.append(('f2c_math', 'ctmath', ['cpp','c'])) + # Create arith.h using the arithchk program if not os.path.exists('arith.h'): arithenv = env.Clone() @@ -22,13 +24,15 @@ if env['build_with_f2c']: localenv.Command('f2c_libs/signal1.h', 'f2c_libs/signal1.h0', CopyNoPrefix(build)) localenv.Command('f2c_libs/sysdep1.h', 'f2c_libs/sysdep1.h0', CopyNoPrefix(build)) - libs.append(('f2c_libs', 'f2c', 'c')) + libs.append(('f2c_libs', 'ctf2c', 'c')) if env['BUILD_BLAS_LAPACK']: libs.append(('f2c_blas', 'ctblas', ('c'))) libs.append(('f2c_lapack', 'ctlapack', ('c'))) else: + libs.append(('math', 'ctmath', ['cpp','c','f'])) + if env['BUILD_BLAS_LAPACK']: libs.append(('blas', 'ctblas', ('f'))) libs.append(('lapack', 'ctlapack', ('f')))