diff --git a/src/SConstruct b/src/SConstruct index a95c803..6fe5cc1 100644 --- a/src/SConstruct +++ b/src/SConstruct @@ -1,9 +1,6 @@ -from sysconfig import get_config_var import os ############################################################################### -suffix = get_config_var('EXT_SUFFIX') - def filtered_glob(env, pattern, omit=[], ondisk=True, source=False, strings=False): return list(filter( @@ -12,27 +9,26 @@ def filtered_glob(env, pattern, omit=[], # Create a builder for f2py def f2py_generator(source, target, env, for_signature): + suffix = ".so" main = source[0] objects = " ".join(o.get_path() for o in source[1:] if str(o).endswith('.o')) - modulename = str(target[0]).replace(suffix, '').replace('/', '.') + moduledir = os.path.dirname(target[0].abspath) + modulefile = str(target[0]) + modulename = modulefile.replace(suffix, '').replace('/', '.') compiler = env['FORTRAN'] cmd = f"f2py3 --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" return cmd -def f2py_emitter(target, source, env): - """ used to add the correct cpython .so suffix to the modulename """ - target[0] = str(target[0]).replace('.', '/') + suffix - return target, source - def install_module(env, module): destdir = os.path.dirname(module[0].srcnode().abspath) env.Install(destdir, module) env.Alias('install', destdir) return None -f2py_bld = Builder(generator=f2py_generator, emitter=f2py_emitter) +f2py_bld = Builder(generator=f2py_generator) # define the default build environment std = Environment(tools=['default', 'fortran'], F2PY_OPTS=[], LIBS=[]) diff --git a/src/msspec/phagen/fortran/SConstruct b/src/msspec/phagen/fortran/SConstruct index c83bfdd..3716a3d 100644 --- a/src/msspec/phagen/fortran/SConstruct +++ b/src/msspec/phagen/fortran/SConstruct @@ -4,7 +4,7 @@ import os objects_src= ['phagen_scf_2.1_dp.f'] objects = env.Object(objects_src) -module = env.F2py('libphagen', ['main.f'] + objects, F2PYCOMSTR=">>") +module = env.F2py('libphagen.so', ['main.f'] + objects, F2PYCOMSTR=">>") env.InstallModule(module) env.Alias('phagen', module) diff --git a/src/msspec/spec/fortran/SConstruct b/src/msspec/spec/fortran/SConstruct index 3fd43b2..18ef38c 100644 --- a/src/msspec/spec/fortran/SConstruct +++ b/src/msspec/spec/fortran/SConstruct @@ -45,19 +45,19 @@ Requires(memalloc_obj, dim_mod_obj) common_deps = dim_mod_obj + memalloc_obj + cluster_gen_obj + common_sub_obj deps = common_deps + renormalization_obj + phd_se_noso_nosp_nosym_obj -phd_se_mod = env_spec.F2py('_phd_se_noso_nosp_nosym', ['phd_se_noso_nosp_nosym/main.f'] + deps) +phd_se_mod = env_spec.F2py('_phd_se_noso_nosp_nosym.so', ['phd_se_noso_nosp_nosym/main.f'] + deps) env_spec.InstallModule(phd_se_mod) deps = common_deps + renormalization_obj + phd_mi_noso_nosp_nosym_obj -phd_mi_mod = env_spec.F2py('_phd_mi_noso_nosp_nosym', ['phd_mi_noso_nosp_nosym/main.f'] + deps) +phd_mi_mod = env_spec.F2py('_phd_mi_noso_nosp_nosym.so', ['phd_mi_noso_nosp_nosym/main.f'] + deps) env_spec.InstallModule(phd_mi_mod) deps = common_deps + renormalization_obj + eig_common_obj + eig_mi_obj -eig_mi_mod = env_spec.F2py('_eig_mi', ['eig/mi/main.f'] + deps) +eig_mi_mod = env_spec.F2py('_eig_mi.so', ['eig/mi/main.f'] + deps) env_spec.InstallModule(eig_mi_mod) deps = common_deps + renormalization_obj + eig_common_obj + eig_pw_obj -eig_pw_mod = env_spec.F2py('_eig_pw', ['eig/pw/main.f'] + deps) +eig_pw_mod = env_spec.F2py('_eig_pw.so', ['eig/pw/main.f'] + deps) env_spec.InstallModule(eig_pw_mod) # Alias