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
MAINT: Trim backend.py down to f2py2e flags
  • Loading branch information
HaoZeke committed Sep 2, 2023
commit 384aa9640c51d4ddf23b195e389eee442eded62b
133 changes: 23 additions & 110 deletions numpy/f2py/backends/backend.py
Original file line number Diff line number Diff line change
@@ -1,125 +1,38 @@
from __future__ import annotations

from pathlib import Path
from abc import ABC, abstractmethod

import numpy
import numpy.f2py as f2py


class Backend(ABC):
"""
Superclass for backend compilation plugins to extend.
"""

def __init__(
self,
module_name,
fortran_compiler: str,
c_compiler: str,
f77exec: Path,
f90exec: Path,
f77_flags: list[str],
f90_flags: list[str],
include_paths: list[Path],
include_dirs: list[Path],
external_resources: list[str],
linker_libpath: list[Path],
linker_libname: list[str],
define_macros: list[tuple[str, str]],
undef_macros: list[str],
debug: bool,
opt_flags: list[str],
arch_flags: list[str],
no_opt: bool,
no_arch: bool,
) -> None:
"""
The class is initialized with f2py compile options.
The parameters are mappings of f2py compilation flags.
Parameters
----------
module_name : str
The name of the module to be compiled. (-m)
fortran_compiler : str
Name of the Fortran compiler to use. (--fcompiler)
c_compiler : str
Name of the C compiler to use. (--ccompiler)
f77exec : Pathlike
Path to the fortran compiler for Fortran 77 files (--f77exec)
f90exec : Pathlike
Path to the fortran compiler for Fortran 90 and above files (--f90exec)
f77_flags : list
List of flags to pass to the fortran compiler for Fortran 77 files (--f77flags)
f90_flags : list
List of flags to pass to the fortran compiler for Fortran 90 and above files (--f90flags)
include_paths : list
Search include files from given directories (--include-paths)
include_dirs : list
Append directory <dir> to the list of directories searched for include files. (-I<dir>)
external_resources : list
Link the extension module with <resource> (--link-<resource>)
linker_libname : list
Use the library when linking. (-l<libname>)
define_macros : list
Define <macro> to <value> if present else define <macro> to true (-D)
undef_macros : list
Undefine <macro> (-U)
linker_libpath : list
Add directory to the list of directories to be searched for `-l`. (-L)
opt_flags : list
Optimization flags to pass to the compiler. (--opt)
arch_flags : list
Architectire specific flags to pass to the compiler (--arch)
no_opt : bool
Disable optimization. (--no-opt)
no_arch : bool
Disable architecture specific optimizations. (--no-arch)
debug : bool
Enable debugging. (--debug)
"""
self.module_name = module_name
self.fortran_compiler = fortran_compiler
self.c_compiler = c_compiler
self.f77exec = f77exec
self.f90exec = f90exec
self.f77_flags = f77_flags
self.f90_flags = f90_flags
self.include_paths = include_paths
modulename,
include_dirs,
library_dirs,
libraries,
define_macros,
undef_macros,
f2py_flags,
sysinfo_flags,
fc_flags,
flib_flags,
setup_flags,
remove_build_dir,
):
self.modulename = modulename
self.include_dirs = include_dirs
self.external_resources = external_resources
self.linker_libpath = linker_libpath
self.linker_libname = linker_libname
self.library_dirs = library_dirs
self.libraries = libraries
self.define_macros = define_macros
self.undef_macros = undef_macros
self.debug = debug
self.opt_flags = opt_flags
self.arch_flags = arch_flags
self.no_opt = no_opt
self.no_arch = no_arch

def numpy_install_path(self) -> Path:
"""
Returns the install path for numpy.
"""
return Path(numpy.__file__).parent

def numpy_get_include(self) -> Path:
"""
Returns the include paths for numpy.
"""
return Path(numpy.get_include())

def f2py_get_include(self) -> Path:
"""
Returns the include paths for f2py.
"""
return Path(f2py.get_include())
self.f2py_flags = f2py_flags
self.sysinfo_flags = sysinfo_flags
self.fc_flags = fc_flags
self.flib_flags = flib_flags
self.setup_flags = setup_flags
self.remove_build_dir = remove_build_dir

@abstractmethod
def compile(self, fortran_sources: Path, c_wrapper: Path, build_dir: Path) -> None:
def compile(self, sources, extra_objects, build_dir) -> None:
"""Compile the wrapper."""
pass
0