Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13e4f44
🐛 remove spurious `f2py.compile` function
jorenham Mar 7, 2025
a4d71eb
🏷️ stub `numpy.f2py.__version__`
jorenham Mar 7, 2025
6a9b380
🏷️ stub `numpy.f2py.cfuncs`
jorenham Mar 7, 2025
5008c6b
🏷️ stub `numpy.f2py.auxfuncs`
jorenham Mar 7, 2025
fa8d11c
🏷️ stub `numpy.f2py.capi_maps`
jorenham Mar 7, 2025
4f27b4f
🏷️ stub `numpy.f2py.f2py2e`
jorenham Mar 7, 2025
0709670
🏷️ stub `numpy.f2py.diagnose`
jorenham Mar 7, 2025
32ab814
🏷️ stub `numpy.f2py.func2subr`
jorenham Mar 7, 2025
f6a4fef
🏷️ stub `numpy.f2py.symbolic`
jorenham Mar 7, 2025
825cc9b
🩹 broaden callalble return type
jorenham Mar 7, 2025
eefe391
🏷️ stub `numpy.f2py.rules`
jorenham Mar 7, 2025
b75be6e
🏷️ stub `numpy.f2py.use_rules`
jorenham Mar 7, 2025
d653e8c
🏷️ stub `numpy.f2py.f90mod_rules`
jorenham Mar 7, 2025
14c5012
🏷️ stub `numpy.f2py.common_rules`
jorenham Mar 7, 2025
b4c9b3c
🏷️ stub `numpy.f2py.cb_rules`
jorenham Mar 7, 2025
d572d89
🏷️ stub `numpy.f2py.crackfortran`
jorenham Mar 8, 2025
6647cb4
🏷️ stub `numpy.f2py._src_pyf`
jorenham Mar 8, 2025
e693b84
🏷️ stub `numpy.f2py._isocbind`
jorenham Mar 8, 2025
3f44b76
🏷️ stub `numpy.f2py._backends.*`
jorenham Mar 8, 2025
4539f5d
🩹 fix `typing_extensions` imports
jorenham Mar 8, 2025
01ee5e5
🙈 ignore non-existent `numpy.f2py` submodules
jorenham Mar 8, 2025
562e6e9
✏️ bow down to the `self` -> `sef` typo
jorenham Mar 8, 2025
3eeb74b
🏷️ fill in the remaining `Incomplete` in `numpy.f2py`
jorenham Mar 10, 2025
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
42 changes: 1 addition & 41 deletions src/numpy-stubs/f2py/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
import subprocess
from _typeshed import StrOrBytesPath
from collections.abc import Iterable
from typing import Literal as L, TypedDict, overload, type_check_only
from .f2py2e import main as main, run_main

__all__ = ["get_include", "run_main"]

@type_check_only
class _F2PyDictBase(TypedDict):
csrc: list[str]
h: list[str]

@type_check_only
class _F2PyDict(_F2PyDictBase, total=False):
fsrc: list[str]
ltx: list[str]

#
def get_include() -> str: ...

#
def run_main(comline_list: Iterable[str]) -> dict[str, _F2PyDict]: ...

#
@overload
def compile(
source: str | bytes,
modulename: str = ...,
extra_args: str | list[str] = ...,
verbose: bool = ...,
source_fn: StrOrBytesPath | None = ...,
extension: L[".f", ".f90"] = ...,
full_output: L[False] = ...,
) -> int: ...
@overload
def compile(
source: str | bytes,
modulename: str = ...,
extra_args: str | list[str] = ...,
verbose: bool = ...,
source_fn: StrOrBytesPath | None = ...,
extension: L[".f", ".f90"] = ...,
*,
full_output: L[True],
) -> subprocess.CompletedProcess[bytes]: ...
1 change: 1 addition & 0 deletions src/numpy-stubs/f2py/__version__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from numpy.version import version as version
5 changes: 5 additions & 0 deletions src/numpy-stubs/f2py/_backends/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing import Literal as L

from ._backend import Backend

def f2py_build_generator(name: L["distutils", "meson"]) -> Backend: ...
46 changes: 46 additions & 0 deletions src/numpy-stubs/f2py/_backends/_backend.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import abc
from pathlib import Path
from typing import Any, Final

class Backend(abc.ABC):
modulename: Final[str]
sources: Final[list[str | Path]]
extra_objects: Final[list[str]]
build_dir: Final[str | Path]
include_dirs: Final[list[str | Path]]
library_dirs: Final[list[str | Path]]
libraries: Final[list[str]]
define_macros: Final[list[tuple[str, str | None]]]
undef_macros: Final[list[str]]
f2py_flags: Final[list[str]]
sysinfo_flags: Final[list[str]]
fc_flags: Final[list[str]]
flib_flags: Final[list[str]]
setup_flags: Final[list[str]]
remove_build_dir: Final[bool]
extra_dat: Final[dict[str, Any]]

def __init__(
self,
/,
modulename: str,
sources: list[str | Path],
extra_objects: list[str],
build_dir: str | Path,
include_dirs: list[str | Path],
library_dirs: list[str | Path],
libraries: list[str],
define_macros: list[tuple[str, str | None]],
undef_macros: list[str],
f2py_flags: list[str],
sysinfo_flags: list[str],
fc_flags: list[str],
flib_flags: list[str],
setup_flags: list[str],
remove_build_dir: bool,
extra_dat: dict[str, Any],
) -> None: ...

#
@abc.abstractmethod
def compile(self) -> None: ...
12 changes: 12 additions & 0 deletions src/numpy-stubs/f2py/_backends/_distutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from typing_extensions import deprecated

from ._backend import Backend

class DistutilsBackend(Backend):
@deprecated(
"distutils has been deprecated since NumPy 1.26.x. Use the Meson backend instead, or generate wrappers without -c and "
"use a custom build script"
)
# NOTE: the `sef` typo matches runtime
def __init__(sef, *args: object, **kwargs: object) -> None: ...
def compile(self) -> None: ...
59 changes: 59 additions & 0 deletions src/numpy-stubs/f2py/_backends/_meson.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from collections.abc import Callable
from pathlib import Path
from typing import Final, Literal as L

from ._backend import Backend

class MesonTemplate:
modulename: Final[str]
build_template_path: Final[Path]
sources: Final[list[str | Path]]
deps: Final[list[str]]
libraries: Final[list[str]]
library_dirs: Final[list[str | Path]]
include_dirs: Final[list[str | Path]]
substitutions: Final[dict[str, str]]
objects: Final[list[str | Path]]
fortran_args: Final[list[str]]
pipeline: Final[list[Callable[[], None]]]
build_type: Final[str]
python_exe: Final[str]
indent: Final[str]

def __init__(
self,
/,
modulename: str,
sources: list[Path],
deps: list[str],
libraries: list[str],
library_dirs: list[str | Path],
include_dirs: list[str | Path],
object_files: list[str | Path],
linker_args: list[str],
fortran_args: list[str],
build_type: str,
python_exe: str,
) -> None: ...

#
def initialize_template(self) -> None: ...
def sources_substitution(self) -> None: ...
def deps_substitution(self) -> None: ...
def libraries_substitution(self) -> None: ...
def include_substitution(self) -> None: ...
def fortran_args_substitution(self) -> None: ...

#
def meson_build_template(self) -> str: ...
def generate_meson_build(self) -> str: ...

class MesonBackend(Backend):
dependencies: list[str]
meson_build_dir: L["bdir"]
build_type: L["debug", "release"]

def __init__(self, /, *args: object, **kwargs: object) -> None: ...
def write_meson_build(self, /, build_dir: Path) -> None: ...
def run_meson(self, /, build_dir: Path) -> None: ...
def compile(self) -> None: ...
13 changes: 13 additions & 0 deletions src/numpy-stubs/f2py/_isocbind.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Any, Final

iso_c_binding_map: Final[dict[str, dict[str, str]]] = ...

isoc_c2pycode_map: Final[dict[str, Any]] = {} # not implemented
iso_c2py_map: Final[dict[str, Any]] = {} # not implemented

isoc_kindmap: Final[dict[str, str]] = ...

# namespace pollution
c_type: str
c_type_dict: dict[str, str]
fortran_type: str
28 changes: 28 additions & 0 deletions src/numpy-stubs/f2py/_src_pyf.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import re
from _typeshed import StrOrBytesPath
from collections.abc import Mapping
from typing import Final

routine_start_re: Final[re.Pattern[str]] = ...
routine_end_re: Final[re.Pattern[str]] = ...
function_start_re: Final[re.Pattern[str]] = ...
template_re: Final[re.Pattern[str]] = ...
named_re: Final[re.Pattern[str]] = ...
list_re: Final[re.Pattern[str]] = ...
item_re: Final[re.Pattern[str]] = ...
template_name_re: Final[re.Pattern[str]] = ...
include_src_re: Final[re.Pattern[str]] = ...

def parse_structure(astr: str) -> list[tuple[int, int]]: ...
def find_repl_patterns(astr: str) -> dict[str, str]: ...
def find_and_remove_repl_patterns(astr: str) -> tuple[str, dict[str, str]]: ...
def conv(astr: str) -> str: ...

#
def unique_key(adict: Mapping[str, object]) -> str: ...
def expand_sub(substr: str, names: dict[str, str]) -> str: ...
def process_str(allstr: str) -> str: ...

#
def resolve_includes(source: StrOrBytesPath) -> list[str]: ...
def process_file(source: StrOrBytesPath) -> str: ...
Loading