diff --git a/platform/posix/SConscript b/platform/posix/SConscript index 7c55cc245..a3a20130a 100644 --- a/platform/posix/SConscript +++ b/platform/posix/SConscript @@ -11,19 +11,31 @@ if env['INSTALL_MANPAGES']: ### Generate customized scripts ### +# If any Python 3 package is built, prefer that one. If not, +# and if any Python 2 package is built, prefer that one. +# In all other cases, use the Python 3 location variables, +# which should all be empty strings +if env['python3_package'] in ['full', 'minimal']: + major = '3' +elif env['python2_package'] in ['full', 'minimal']: + major = '2' +else: + major = '3' + # 'setup_cantera' if localenv['layout'] != 'debian' and env['OS'] != 'Windows': - v = sys.version_info def copy_var(target, source, env): - if env['python_prefix'] == 'USER': + if env['python{}_prefix'.format(major)] == 'USER': env['python_module_loc_sc'] = '' else: - env['python_module_loc_sc'] = env['python_module_loc'] + env['python_module_loc_sc'] = env['python{}_module_loc'.format(major)] + env['python_cmd'] = env['python{}_cmd'.format(major)] + env['python_array_home'] = env['python{}_array_home'.format(major)] target = env.SubstFile('setup_cantera', 'setup_cantera.in') localenv.AddPreAction(target, copy_var) - localenv.Depends(target, env['install_python2_action']) + localenv.Depends(target, env['install_python{}_action'.format(major)]) install('$inst_bindir', target) # Cantera.mak include file for Makefile projects diff --git a/platform/posix/setup_cantera.in b/platform/posix/setup_cantera.in index b40cc185c..81fd48324 100644 --- a/platform/posix/setup_cantera.in +++ b/platform/posix/setup_cantera.in @@ -35,9 +35,9 @@ fi if [ "@python_module_loc_sc@" != "" ]; then if [ -z $PYTHONPATH ]; then - PYTHONPATH=@python_module_loc@ + PYTHONPATH=@python_module_loc_sc@ else - PYTHONPATH=@python_module_loc@:$PYTHONPATH + PYTHONPATH=@python_module_loc_sc@:$PYTHONPATH fi fi diff --git a/src/matlab/SConscript b/src/matlab/SConscript index ff33ad7b1..cd455a233 100644 --- a/src/matlab/SConscript +++ b/src/matlab/SConscript @@ -79,16 +79,29 @@ env['matlab_extension'] = ctmethods # 'ctpath.m' globalenv = env + +# If any Python 3 package is built, prefer that one. If not, +# and if any Python 2 package is built, prefer that one. +# In all other cases, use the Python 3 location variables, +# which should all be empty strings +if env['python3_package'] in ['full', 'minimal']: + major = '3' +elif env['python2_package'] in ['full', 'minimal']: + major = '2' +else: + major = '3' + def copy_var(target, source, env): - if env['python_prefix'] == 'USER': + if env['python{}_prefix'.format(major)] == 'USER': env['python_module_loc_sc'] = '' else: - env['python_module_loc_sc'] = globalenv['python_module_loc'] + env['python_module_loc_sc'] = globalenv['python{}_module_loc'.format(major)] + env['python_cmd'] = env['python{}_cmd'.format(major)] target = localenv.SubstFile('#interfaces/matlab/ctpath.m', '#interfaces/matlab/ctpath.m.in') localenv.AddPreAction(target, copy_var) -localenv.Depends(target, env['install_python2_action']) +localenv.Depends(target, env['install_python{}_action'.format(major)]) install('$inst_matlab_dir', target) # 'Contents.m'