8000 ENH: ``meson`` backend for ``f2py`` by HaoZeke · Pull Request #24532 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: meson backend for f2py #24532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Sep 5, 2023
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fe49281
FIX: Import f2py2e rather than f2py for run_main
NamamiShanker Jul 11, 2022
6b1475e
FIX: Import f2py2e instead of f2py
NamamiShanker Jul 12, 2022
91f3825
ENH: Add F2PY back-end work from gh-22225
HaoZeke Aug 24, 2023
a0b01c3
ENH: Add meson skeleton from gh-2225
HaoZeke Aug 24, 2023
384aa96
MAINT: Trim backend.py down to f2py2e flags
HaoZeke Aug 25, 2023
26b224f
ENH: Add a factory function for backends
HaoZeke Aug 25, 2023
3a5c43d
ENH: Add a distutils backend
HaoZeke Aug 25, 2023
d03d28d
ENH: Handle --backends in f2py
HaoZeke Aug 25, 2023
1d279bc
DOC: Add some minor comments in f2py2e
HaoZeke Aug 25, 2023
0f0e3ac
MAINT: Refactor and rework meson.build.src
HaoZeke Aug 25, 2023
323fa5b
MAINT: Add objects
HaoZeke Aug 25, 2023
8d4368b
MAINT: Cleanup distutils backend
HaoZeke Aug 25, 2023
7bd8c34
MAINT: Refactor to add everything back to backend
HaoZeke Aug 25, 2023
d7a1ea9
MAINT: Fix overly long line
HaoZeke Aug 25, 2023
a95e71a
BUG: Construct wrappers for meson backend
HaoZeke Aug 25, 2023
0621032
MAINT: Rework, simplify template massively
HaoZeke Aug 25, 2023
677e42a
ENH: Truncate meson.build to skeleton only
HaoZeke Aug 25, 2023
2517afe
MAINT: Minor backend housekeeping, name changes
HaoZeke Aug 25, 2023
1dc2733
MAINT: Less absolute paths, update setup.py [f2py]
HaoZeke Aug 25, 2023
42a15ac
MAINT: Move f2py module name functionality
HaoZeke Aug 25, 2023
6776dba
ENH: Handle .pyf files
HaoZeke Aug 25, 2023
0357ab8
TST: Fix typo in isoFortranEnvMap.f90
HaoZeke Aug 25, 2023
5faec2f
MAINT: Typo in f2py2e support for pyf files
HaoZeke Aug 25, 2023
5b79487
DOC: Add release note for --backend
HaoZeke Aug 25, 2023
faadb6d
MAINT: Conditional switch for Python 3.12 [f2py]
HaoZeke Aug 25, 2023
82a4f8f
MAINT: No absolute paths in backend [f2py-meson]
HaoZeke Aug 25, 2023
6585458
MAINT: Prettier generated meson.build files [f2py]
HaoZeke Aug 25, 2023
f85581e
ENH: Add meson's dependency(blah) to f2py
HaoZeke Aug 25, 2023
16f22ee
DOC: Document the new flag
HaoZeke Aug 25, 2023
c0c6bf1
MAINT: Simplify and rename backend template [f2py]
HaoZeke Aug 26, 2023
fa06f8d
ENH: Support build_type via --debug [f2py-meson]
HaoZeke Aug 26, 2023
8841647
MAINT,DOC: Reduce warn,rework doc [f2py-meson]
HaoZeke Aug 26, 2023
8f214a0
ENH: Rework deps: to --dep calls [f2py-meson]
HaoZeke Aug 26, 2023
bc37684
MAINT,DOC: Add --backend to argparse, add docs
HaoZeke Aug 26, 2023
4e3336b
MAINT: Rename meson template [f2py-meson]
HaoZeke Aug 26, 2023
518074e
MAINT: Add meson.build for f2py
HaoZeke Aug 29, 2023
cc92d2c
BLD: remove duplicate f2py handling in meson.build files
rgommers Sep 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: Rework deps: to --dep calls [f2py-meson]
Also shows how incremental updates to the parser can be done.
  • Loading branch information
HaoZeke committed Sep 2, 2023
commit 8f214a0118ef3ac0c7739706753663923086b302
42 changes: 21 additions & 21 deletions numpy/f2py/f2py2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re
from pathlib import Path
from itertools import dropwhile
import argparse

from . import crackfortran
from . import rules
Expand Down Expand Up @@ -143,20 +144,16 @@
--noopt Compile without optimization
--noarch Compile without arch-dependent optimization
--debug Compile with debugging information
deps: <dependency1> <dependency2> ... :
Specify additional dependencies that the module relies on.
List dependencies separated by spaces, and use `:' to
signify the end of the dependency list. Dependencies are
stored in a list for further processing.
--dep <dependency>
Specify a meson dependencies for the module. This may
be passed multiple times for multiple dependencies.
Dependencies are stored in a list for further processing.

Example: deps: lapack scalapack :
Example: --dep lapack --dep scalapack
This will identify "lapack" and "scalapack" as dependencies
and remove them from argv, leaving a dependencies list
containing ["lapack", "scalapack"].

Note: The trailing `:' is required to signify the end of
the dependency list. This is only relevant for the meson backend.

Extra options (only effective with -c):

--link-<resource> Link extension module with <resource> as defined
Expand Down Expand Up @@ -518,13 +515,28 @@ def get_prefix(module):
p = os.path.dirname(os.path.dirname(module.__file__))
return p

def preparse_sysargv():
# To keep backwards bug compatibility, newer flags are handled by argparse,
# and `sys.argv` is passed to the rest of `f2py` as is.
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--dep", action="append", dest="dependencies")
args, remaining_argv = parser.parse_known_args()
sys.argv = [sys.argv[0]] + remaining_argv
return {
"dependencies": args.dependencies or [],
}


def run_compile():
"""
Do it all in one call!
"""
import tempfile

# Collect dependency flags, preprocess sys.argv
argparse_res = preparse_sysargv()
dependencies = argparse_res["dependencies"]

i = sys.argv.index('-c')
del sys.argv[i]

Expand Down Expand Up @@ -563,18 +575,6 @@ def run_compile():
if f2py_flags2 and f2py_flags2[-1] != ':':
f2py_flags2.append(':')
f2py_flags.extend(f2py_flags2)
# Find the start and end indices of the "deps:" section
start_idx = next((i for i, a in enumerate(sys.argv) if a == "deps:"), None)
end_idx = next((i for i, a in enumerate(sys.argv) if a == ":" and i > start_idx), None) if start_idx is not None else None
# Extract dependencies and remove them from sys.argv
if start_idx is not None and end_idx is not None:
dependencies = sys.argv[start_idx + 1:end_idx]
del sys.argv[start_idx:end_idx + 1]
elif start_idx is not None:
dependencies = list(dropwhile(lambda x: x != ":", sys.argv[start_idx + 1:]))
del sys.argv[start_idx:]
else:
dependencies = []
sys.argv = [_m for _m in sys.argv if _m not in f2py_flags2]
_reg3 = re.compile(
r'--((f(90)?compiler(-exec|)|compiler)=|help-compiler)')
Expand Down
0