Skip to content
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

Meson port #184

Merged
merged 4 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ cirrus_wheels_macos_arm64_task:
image: ghcr.io/cirruslabs/macos-monterey-xcode:13.3.1
matrix:
- env:
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
CIBW_BUILD: cp38-*
CIBW_BEFORE_ALL: bash tools/wheels/cibw_before_all_cp38_macosx_arm64.sh
- env:
CIBW_BUILD: cp39-* cp310-* cp311-*
env:
PATH: /opt/homebrew/opt/python@3.10/bin:$PATH
CIBW_ENVIRONMENT: MACOSX_DEPLOYMENT_TARGET=12.0 _PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
Expand Down
44 changes: 44 additions & 0 deletions f90wrap/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
f2py = [py3, '-m', 'numpy.f2py', '@INPUT@', '--build-dir', '@OUTDIR@', '--lower']

sizeof_source = custom_target(
input: 'sizeoffortran.f90',
output: 'sizeof_fortran_tmodule.c',
command: f2py + ['-m', 'sizeof_fortran_t']
)

py3.extension_module(
'sizeof_fortran_t',
'sizeoffortran.f90', sizeof_source,
dependencies: fortranobject_dep,
install: true,
subdir: 'f90wrap',
)

py3.extension_module(
'arraydata',
'arraydatamodule.c',
dependencies: fortranobject_dep,
install: true,
subdir: 'f90wrap',
)

py3.install_sources(
'codegen.py',
'f90wrapgen.py',
'fortran.py',
'fortrantype.py',
'__init__.py',
'latex.py',
'__main__.py',
'parser.py',
'pywrapgen.py',
'runtime.py',
'six.py',
'transform.py',
'scripts/f2py_f90wrap.py',
'scripts/f90doc.py',
'scripts/__init__.py',
'scripts/main.py',
subdir: 'f90wrap',
preserve_path: true,
)
8 changes: 8 additions & 0 deletions get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3

version = {}
with open('f90wrap/__init__.py') as fp:
exec(fp.read(), version)
__version__ = version['__version__']

print(__version__)
41 changes: 41 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# much of this file is derived from SciPy

project('f90wrap',
'c',
version: run_command('get_version.py', check: true).stdout().strip(),
meson_version: '>= 0.64.0',
)

# force rebuild to re-calculate the version if it changes
import('fs').read('f90wrap/__init__.py')

# Adding at project level causes many spurious -lgfortran flags.
add_languages('fortran', native: false)

py3 = import('python').find_installation(pure: false)
py3_dep = py3.dependency()

incdir_numpy = run_command(
py3, '-c',
'import numpy; print(numpy.get_include())',
check: true,
).stdout().strip()

inc_np = include_directories(incdir_numpy)

incdir_f2py = incdir_numpy / '..' / '..' / 'f2py' / 'src'
inc_f2py = include_directories(incdir_f2py)
fortranobject_c = incdir_f2py / 'fortranobject.c'

# Share this object across multiple modules.
fortranobject_lib = static_library('_fortranobject',
fortranobject_c,
dependencies: py3_dep,
include_directories: [inc_np, inc_f2py],
)
fortranobject_dep = declare_dependency(
link_with: fortranobject_lib,
include_directories: [inc_np, inc_f2py],
)

subdir('f90wrap')
22 changes: 20 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"
requires = ["meson-python>=0.12.0", "oldest-supported-numpy"]
build-backend = 'mesonpy'

[project]
name = "f90wrap"
description = "Fortran to Python interface generator with derived type support"
authors = [{name = "James Kermode", email = "james.kermode@gmail.com"}]
python-requires = ">=3.6"
urls = {Homepage = "https://github.com/jameskermode/f90wrap"}
dependencies = ["numpy>=1.13,<1.24"]
dynamic = ["version"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.scripts]
f90doc = "f90wrap.scripts.f90doc:main"
f90wrap = "f90wrap.scripts.main:main"
f2py-f90wrap = "f90wrap.scripts.f2py_f90wrap:main"
7 changes: 0 additions & 7 deletions scripts/f2py-f90wrap

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/f90doc

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/f90wrap

This file was deleted.

68 changes: 0 additions & 68 deletions setup.py

This file was deleted.

4 changes: 4 additions & 0 deletions tools/wheels/cibw_before_all_cp38_macosx_arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://cibuildwheel.readthedocs.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64
curl -o /tmp/Python38.pkg https://www.python.org/ftp/python/3.8.10/python-3.8.10-macos11.pkg
sudo installer -pkg /tmp/Python38.pkg -target /
sh "/Applications/Python 3.8/Install Certificates.command"