diff --git a/src/SConstruct b/src/SConstruct index 196886a..5673fa9 100644 --- a/src/SConstruct +++ b/src/SConstruct @@ -1,4 +1,5 @@ import os +import subprocess ############################################################################### def filtered_glob(env, pattern, omit=[], @@ -16,7 +17,8 @@ def f2py_generator(source, target, env, for_signature): modulefile = str(target[0]) modulename = modulefile.replace(suffix, '').replace('/', '.') compiler = env['FORTRAN'] - cmd = f"f2py3 --fcompiler={compiler} " + + cmd = f"$F2PY --fcompiler={compiler} " cmd += f" $F2PY_OPTS -m {modulename} -c {objects} {main}" cmd += f" && cp {'/'.join(modulename.split('.'))}.*.so {modulefile}" #cmd += " 1>/dev/null 2>/dev/null" @@ -55,6 +57,10 @@ AddOption('--compiler', choices=['gfortran', 'ifort'], help='The Fortran compiler to use') +AddOption('--f2py_path', + dest='f2py_path', + default='f2py3', + help='The full path to the f2py compiler') @@ -71,6 +77,13 @@ if GetOption('compiler') == 'gfortran': elif GetOption('compiler') == 'ifort': env = ifort_env +f2py_path = GetOption('f2py_path') +p = subprocess.run(['which', f2py_path], stdout=subprocess.PIPE) +if p.returncode != 0: + raise Exception('Invalid path for f2py compiler!') +else: + env.Append(F2PY=p.stdout.decode('utf8').strip()) + if GetOption('dbg'): gfortran_env.Append(FORTRANFLAGS = ['-g', '-Wall', '-Wextra', '-Warray-temporaries', '-Wconversion', '-fbacktrace', '-ffree-line-length-0',