Skip to content

Commit

Permalink
WIP: BLD: use a generator for f2py
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Apr 29, 2024
1 parent e15716b commit 4a14bdb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
9 changes: 1 addition & 8 deletions scipy/linalg/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ py3.extension_module('_flapack',

# TODO: cblas/clapack are built *only* for ATLAS. Why? Is it still needed?

# _interpolative
interpolative_module = custom_target('interpolative_module',
output: '_interpolativemodule.c',
input: 'interpolative.pyf',
command: [generate_f2pymod, '@INPUT@', '-o', '@OUTDIR@']
)

# id_dist contains a copy of FFTPACK, which has type mismatch warnings
# that are hard to fix. This code is terrible and noisy during the build,
# silence it completely.
Expand Down Expand Up @@ -159,7 +152,7 @@ py3.extension_module('_interpolative',
'src/id_dist/src/idzr_rid.f',
'src/id_dist/src/idzr_rsvd.f',
'src/id_dist/src/prini.f',
interpolative_module,
f2py_gen.process('interpolative.pyf'),
],
fortran_args: [fortran_ignore_warnings, _suppress_all_warnings],
link_args: version_link_args,
Expand Down
7 changes: 7 additions & 0 deletions scipy/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ fortranobject_dep = declare_dependency(
compile_args: _f2py_c_args,
)

f2py = find_program('f2py')
f2py_gen = generator(generate_f2pymod,
arguments : ['@INPUT@', '-o', '@BUILD_DIR@'],
output : ['_@[email protected]', '_@[email protected]'],
)


# TODO: 64-bit BLAS and LAPACK
#
# Note that this works as long as BLAS and LAPACK are detected properly via
Expand Down
13 changes: 7 additions & 6 deletions scipy/stats/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ py3.extension_module('_ansari_swilk_statistics',
subdir: 'scipy/stats'
)

mvn_module = custom_target('mvn_module',
output: ['_mvn-f2pywrappers.f', '_mvnmodule.c'],
input: 'mvn.pyf',
command: [generate_f2pymod, '@INPUT@', '-o', '@OUTDIR@']
)
#mvn_module = custom_target('mvn_module',
# output: ['_mvn-f2pywrappers.f', '_mvnmodule.c'],
# input: 'mvn.pyf',
# command: [generate_f2pymod, '@INPUT@', '-o', '@OUTDIR@']
#)

py3.extension_module('_mvn',
[mvn_module, 'mvndst.f'],
#[mvn_module, 'mvndst.f'],
[f2py_gen.process('mvn.pyf'), 'mvndst.f'],
# Wno-surprising is to suppress a pointless warning with GCC 10-12
# (see GCC bug 98411: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98411)
fortran_args: [fortran_ignore_warnings, _fflag_Wno_surprising],
Expand Down
2 changes: 1 addition & 1 deletion tools/generate_f2pymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def main():

# Now invoke f2py to generate the C API module file
if args.infile.endswith(('.pyf.src', '.pyf')):
p = subprocess.Popen([sys.executable, '-m', 'numpy.f2py', fname_pyf,
p = subprocess.Popen(['f2py', fname_pyf,
'--build-dir', outdir_abs], #'--quiet'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=os.getcwd())
Expand Down

0 comments on commit 4a14bdb

Please sign in to comment.