Skip to content

Commit

Permalink
Merge branch 'main' into arm
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/cygwin.yml
  • Loading branch information
rjfarmer committed Jan 27, 2024
2 parents 4eb5ad9 + 7f3de2a commit 2d0b769
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ jobs:
install-dir: 'C:\tools\cygwin'
packages: >-
python39-devel python39-pip python-pip-wheel python-setuptools-wheel
gcc-fortran git dash python39-numpy automake make python39
liblapack-devel liblapack0 gcc-fortran git dash python39-numpy automake make
- name: pip cache
uses: actions/cache@v4
with:
path: 'C:\cygwin\home\runneradmin\.cache\pip'
key: ${{ runner.os }}-${{ hashFiles('pyproject.toml') }}

- name: Set Windows PATH
uses: egor-tensin/cleanup-path@v3
with:
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml → .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: CI
name: Linux CI
on: [push, pull_request]

jobs:
CI:
linux_ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
os: [ubuntu-20.04, ubuntu-22.04]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
toolchain:
- {compiler: gcc, version: 8}
Expand All @@ -34,25 +34,26 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions build wheel pytest
python -m pip install build wheel pytest
- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Run tox
run: tox -e py
env:
FC: ${{ env.FC }}
_GFORT2PY_TEST_FLAG: 1
- name: Build
run: python -m pip install .


- name: Test
run: python -m pytest -v

46 changes: 46 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: macOS CI
on: [push, pull_request]

jobs:
macos_ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
toolchain:
- {compiler: gcc, version: 8}
- {compiler: gcc, version: 9}
- {compiler: gcc, version: 10}
- {compiler: gcc, version: 11}
- {compiler: gcc, version: 12}
- {compiler: gcc, version: 13}


steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel pytest
- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Build
run: python -m pip install .


- name: Test
run: python -m pytest -v

2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
cache: 'pip'

Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/pypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PyPy
on: [push, pull_request]

jobs:
pypy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- {compiler: gcc, version: 12}

steps:
- uses: actions/checkout@v4
- name: Set up PyPy
uses: actions/setup-python@v5
with:
python-version: 'pypy3.9'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel pytest numpy platformdirs cpyparsing
- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Build
run: pypy3 -m pip install .

- name: Test
run: pypy3 -m pytest -v
2 changes: 1 addition & 1 deletion .github/workflows/qemu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Cache docker container
uses: actions/cache@v3
uses: actions/cache@v4
id: container-cache
with:
path: docker_${TOOLCHAIN_NAME}.tar
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: windows CI
on: [push, pull_request]

jobs:
windows_ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
toolchain:
- {compiler: gcc, version: 8}
- {compiler: gcc, version: 9}
- {compiler: gcc, version: 10}
- {compiler: gcc, version: 11}
- {compiler: gcc, version: 12}
- {compiler: gcc, version: 13}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel pytest
- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Build
run: python -m pip install .


- name: Test
run: python -m pytest -v

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fail_fast: true
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.1.0
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
18 changes: 0 additions & 18 deletions .readthedocs.yml

This file was deleted.

82 changes: 18 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Continuous Integration](https://github.com/rjfarmer/gfort2py/actions/workflows/ci.yml/badge.svg)](https://github.com/rjfarmer/gfort2py/actions/workflows/ci.yml)
[![Continuous Integration](https://github.com/rjfarmer/gfort2py/actions/workflows/linux.yml/badge.svg)](https://github.com/rjfarmer/gfort2py/actions/workflows/linux.yml)
[![Coverage Status](https://coveralls.io/repos/github/rjfarmer/gfort2py/badge.svg?branch=main)](https://coveralls.io/github/rjfarmer/gfort2py?branch=main)
[![PyPI version](https://badge.fury.io/py/gfort2py.svg)](https://badge.fury.io/py/gfort2py)
[![DOI](https://zenodo.org/badge/72889348.svg)](https://zenodo.org/badge/latestdoi/72889348)
Expand Down Expand Up @@ -225,6 +225,12 @@ Quad precision (REAL128) variables are not natively supported by Python thus we
python -m pip install pyquadp
````

or from a git checkout:

````bash
python -m pip install .[qaud]
````

For more details see pyQuadp's documentation, but briefly you can create a
quad precision variable from an ``int``, ``float``, or ``string``. On return you will receive a ``qfloat`` type. This ``qfloat`` type acts like a Python Number, so you can do things like add, multiply, subtract etc this Number with other Numbers (including non-``qfloat`` types).

Expand Down Expand Up @@ -278,13 +284,8 @@ y = x.another_function(f.callback)
## Testing

````bash
pytest
````

or

````bash
tox
python -m pip install .[test]
pytest -v
````

To run unit tests
Expand Down Expand Up @@ -365,62 +366,6 @@ x.b
x.c
````

<!-- ### Procedure pointers:
#### Procedures as arguments
Consider:
````fortran
integer function my_func(func_arg)
integer func_arg
my_func = func_arg(5)
end function my_func
````
Assuming that func_arg is another fortran function then we can call my_func as:
````python
x.my_func(x.func_arg) # With the function itself
````
It is left the the user to make sure that the function func_arg takes the correct inputs and returns the correct output -->


<!-- Needs readding once fixed
#### Procedure pointers
Consider a procedure like:
````fortran
procedure(my_func), pointer:: func_ptr => NULL()
````
This can be set similar to how we handle functions as arguments:
````python
x.func_ptr = x.func_arg # With the function itself
````
Its left the the user to make sure that the function func_arg takes the correct inputs and returns the correct output. If you have a function
that accepts a function pointer then its the same as if the it just accepted a function argument
If func_ptr already points a a function at compile time:
````fortran
procedure(my_func), pointer:: func_ptr => my_func
````
You must still first set it to something
````python
x.func_ptr = x.func_arg # With the function itself
```` -->

## Accessing module file data

For those wanting to explore the module file format, there is a routine ``mod_info`` available from the top-level ``gfort2py`` module:
Expand All @@ -441,6 +386,15 @@ pprint(module['a_variable'])

Accessing the list of all available components can be had via ``module.keys()``.

You can also do:
````python
module = gf.mod_info('file.mod',json=True)
module['a_variable']
````

Then when you access each component the return value will be JSON-formatted. Note you can currently only access each component as JSON not the whole module file as JSON at the moment.


## Contributing

Bug reports are of course welcome and PR's should target the main branch.
Expand Down
4 changes: 2 additions & 2 deletions gfort2py/gfort2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ def __str__(self):
return f"{self._module.filename}"


def mod_info(mod_file, load_only=False):
def mod_info(mod_file, *, load_only=False, json=False):
"""
Returns a parsed data structure that describes the module
pprint is recommened to help understand the nested structure.
"""
return module(mod_file, load_only=load_only)
return module(mod_file, load_only=load_only, json=json)


def lib_ext():
Expand Down
Loading

0 comments on commit 2d0b769

Please sign in to comment.