Skip to content

Commit e5c1d34

Browse files
authored
Merge pull request #184 from eli-schwartz/meson
Meson port
2 parents e73659c + f07513d commit e5c1d34

10 files changed

+121
-92
lines changed

.cirrus.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ cirrus_wheels_macos_arm64_task:
4949
image: ghcr.io/cirruslabs/macos-monterey-xcode:13.3.1
5050
matrix:
5151
- env:
52-
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
52+
CIBW_BUILD: cp38-*
53+
CIBW_BEFORE_ALL: bash tools/wheels/cibw_before_all_cp38_macosx_arm64.sh
54+
- env:
55+
CIBW_BUILD: cp39-* cp310-* cp311-*
5356
env:
5457
PATH: /opt/homebrew/opt/[email protected]/bin:$PATH
5558
CIBW_ENVIRONMENT: MACOSX_DEPLOYMENT_TARGET=12.0 _PYTHON_HOST_PLATFORM="macosx-12.0-arm64"

f90wrap/meson.build

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
f2py = [py3, '-m', 'numpy.f2py', '@INPUT@', '--build-dir', '@OUTDIR@', '--lower']
2+
3+
sizeof_source = custom_target(
4+
input: 'sizeoffortran.f90',
5+
output: 'sizeof_fortran_tmodule.c',
6+
command: f2py + ['-m', 'sizeof_fortran_t']
7+
)
8+
9+
py3.extension_module(
10+
'sizeof_fortran_t',
11+
'sizeoffortran.f90', sizeof_source,
12+
dependencies: fortranobject_dep,
13+
install: true,
14+
subdir: 'f90wrap',
15+
)
16+
17+
py3.extension_module(
18+
'arraydata',
19+
'arraydatamodule.c',
20+
dependencies: fortranobject_dep,
21+
install: true,
22+
subdir: 'f90wrap',
23+
)
24+
25+
py3.install_sources(
26+
'codegen.py',
27+
'f90wrapgen.py',
28+
'fortran.py',
29+
'fortrantype.py',
30+
'__init__.py',
31+
'latex.py',
32+
'__main__.py',
33+
'parser.py',
34+
'pywrapgen.py',
35+
'runtime.py',
36+
'six.py',
37+
'transform.py',
38+
'scripts/f2py_f90wrap.py',
39+
'scripts/f90doc.py',
40+
'scripts/__init__.py',
41+
'scripts/main.py',
42+
subdir: 'f90wrap',
43+
preserve_path: true,
44+
)

get_version.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python3
2+
3+
version = {}
4+
with open('f90wrap/__init__.py') as fp:
5+
exec(fp.read(), version)
6+
__version__ = version['__version__']
7+
8+
print(__version__)

meson.build

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# much of this file is derived from SciPy
2+
3+
project('f90wrap',
4+
'c',
5+
version: run_command('get_version.py', check: true).stdout().strip(),
6+
meson_version: '>= 0.64.0',
7+
)
8+
9+
# force rebuild to re-calculate the version if it changes
10+
import('fs').read('f90wrap/__init__.py')
11+
12+
# Adding at project level causes many spurious -lgfortran flags.
13+
add_languages('fortran', native: false)
14+
15+
py3 = import('python').find_installation(pure: false)
16+
py3_dep = py3.dependency()
17+
18+
incdir_numpy = run_command(
19+
py3, '-c',
20+
'import numpy; print(numpy.get_include())',
21+
check: true,
22+
).stdout().strip()
23+
24+
inc_np = include_directories(incdir_numpy)
25+
26+
incdir_f2py = incdir_numpy / '..' / '..' / 'f2py' / 'src'
27+
inc_f2py = include_directories(incdir_f2py)
28+
fortranobject_c = incdir_f2py / 'fortranobject.c'
29+
30+
# Share this object across multiple modules.
31+
fortranobject_lib = static_library('_fortranobject',
32+
fortranobject_c,
33+
dependencies: py3_dep,
34+
include_directories: [inc_np, inc_f2py],
35+
)
36+
fortranobject_dep = declare_dependency(
37+
link_with: fortranobject_lib,
38+
include_directories: [inc_np, inc_f2py],
39+
)
40+
41+
subdir('f90wrap')

pyproject.toml

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
[build-system]
22
# Minimum requirements for the build system to execute.
3-
requires = ["setuptools", "wheel", "oldest-supported-numpy"]
4-
build-backend = "setuptools.build_meta"
3+
requires = ["meson-python>=0.12.0", "oldest-supported-numpy"]
4+
build-backend = 'mesonpy'
5+
6+
[project]
7+
name = "f90wrap"
8+
description = "Fortran to Python interface generator with derived type support"
9+
authors = [{name = "James Kermode", email = "[email protected]"}]
10+
python-requires = ">=3.6"
11+
urls = {Homepage = "https://github.com/jameskermode/f90wrap"}
12+
dependencies = ["numpy>=1.13,<1.24"]
13+
dynamic = ["version"]
14+
15+
[project.readme]
16+
file = "README.md"
17+
content-type = "text/markdown"
18+
19+
[project.scripts]
20+
f90doc = "f90wrap.scripts.f90doc:main"
21+
f90wrap = "f90wrap.scripts.main:main"
22+
f2py-f90wrap = "f90wrap.scripts.f2py_f90wrap:main"

scripts/f2py-f90wrap

-7
This file was deleted.

scripts/f90doc

-7
This file was deleted.

scripts/f90wrap

-7
This file was deleted.

setup.py

-68
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://cibuildwheel.readthedocs.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64
2+
curl -o /tmp/Python38.pkg https://www.python.org/ftp/python/3.8.10/python-3.8.10-macos11.pkg
3+
sudo installer -pkg /tmp/Python38.pkg -target /
4+
sh "/Applications/Python 3.8/Install Certificates.command"

0 commit comments

Comments
 (0)