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

Add pyproject.toml and support Cython 3 #30

Merged
merged 3 commits into from
Apr 24, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
86 changes: 67 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,77 @@
name: github-CI
name: main

on: [push]
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build:

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
name: Python ${{ matrix.python-version }} example
os:
- ubuntu-latest
- macos-latest
mpi:
- mpich
- openmpi
py:
# - "3.7"
# - "3.8"
# - "3.9"
- "3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: setup-conda
uses: s-weigand/setup-conda@v1

- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
update-conda: true
python-version: ${{ matrix.python-version }}
conda-channels: anaconda, conda-forge
- run: conda --version
- run: which python
python-version: ${{ matrix.py }}

- run: |
conda config --set always_yes yes
conda install -n root conda-build numpy fftw
conda build ./conf
# Install fftw
case $(uname) in
Linux)
sudo apt update
sudo apt install -y -q libfftw3-dev
;;
Darwin)
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew install fftw
;;
esac

- run: python -m pip install -U pip build

- run: python -m build

- uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi }}

- run: pip install -vvv dist/mpi4py_fft-*.whl
env:
CFLAGS: "-O0"

- run: pip install -r conf/requirements-test.txt

- if: matrix.mpi == 'mpich' && startsWith(matrix.os, 'ubuntu')
run: ./runtests.sh
working-directory: tests

- if: matrix.mpi == 'mpich' && startsWith(matrix.os, 'ubuntu')
uses: codecov/codecov-action@v4
with:
files: test/coverage.xml
name: ${{ matrix.os }}-${{ matrix.mpi }}-${{ matrix.py }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ _templates/
*.dat
*.html
*.xml
*.txt
*.h5
*.nc
*.xdmf
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION=$(shell python3 -c "import mpi4py_fft; print(mpi4py_fft.__version__)")

default:
python setup.py build_ext -i
python setup.py build build_ext -i

pip:
rm -f dist/*
Expand All @@ -15,6 +15,6 @@ tag:
publish: tag pip

clean:
git clean mpi4py_fft -fx
git clean -dxf mpi4py_fft
cd docs && make clean && cd ..
@rm -rf *.egg-info/ build/ dist/ .eggs/
@rm -rf *.egg-info/ build/ dist/ .eggs/
83 changes: 0 additions & 83 deletions azure-pipelines.yml

This file was deleted.

4 changes: 2 additions & 2 deletions conf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ requirements:
- {{ compiler('cxx') }}
host:
- python
- cython <3.0
- cython
- numpy
- pip
- fftw
Expand All @@ -25,7 +25,7 @@ requirements:
run:
- python
- mpi4py
- mpich 4.0.2
- mpich
- {{ pin_compatible('numpy') }}
- fftw
- hdf5 * mpi_*
Expand Down
3 changes: 3 additions & 0 deletions conf/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage
pyfftw; sys_platform == 'linux' and python_version < '3.12'
scipy
17 changes: 9 additions & 8 deletions mpi4py_fft/fftw/fftw_xfftn.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cdef extern from "fftw3.h":
# cython: language_level=3str
cdef extern from "fftw3.h" nogil:

ctypedef struct fftw_complex_struct:
pass
Expand All @@ -12,15 +13,15 @@ cdef extern from "fftw3.h":

void fftw_destroy_plan(fftw_plan)

void fftw_execute_dft(fftw_plan, void *_in, void *_out) nogil
void fftw_execute_dft(fftw_plan, void *_in, void *_out)

void fftw_execute_dft_c2r(fftw_plan, void *_in, void *_out) nogil
void fftw_execute_dft_c2r(fftw_plan, void *_in, void *_out)

void fftw_execute_dft_r2c(fftw_plan, void *_in, void *_out) nogil
void fftw_execute_dft_r2c(fftw_plan, void *_in, void *_out)

void fftw_execute_r2r(fftw_plan, void *_in, void *_out) nogil
void fftw_execute_r2r(fftw_plan, void *_in, void *_out)

void fftw_execute(fftw_plan) nogil
void fftw_execute(fftw_plan)

void fftw_init_threads()

Expand All @@ -43,7 +44,7 @@ cdef extern from "fftw3.h":
void fftw_print_plan(fftw_plan)


cdef extern from "fftw_planxfftn.h":
cdef extern from "fftw_planxfftn.h" nogil:

ctypedef double fftw_real

Expand All @@ -57,4 +58,4 @@ cdef extern from "fftw_planxfftn.h":
int kind[],
unsigned flags)

ctypedef void (*generic_function)(void *plan, void *_in, void *_out) nogil
ctypedef void (*generic_function)(void *plan, void *_in, void *_out) noexcept nogil
12 changes: 6 additions & 6 deletions mpi4py_fft/fftw/fftw_xfftn.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cimport fftw_xfftn
#cython: language_level=3
# cython: language_level=3str
from . cimport fftw_xfftn
cimport numpy as np
from .utilities import *
import numpy as np
Expand All @@ -26,16 +26,16 @@ cpdef void cleanup():
fftw_cleanup()
fftw_cleanup_threads()

cdef void _fftw_execute_dft(void *plan, void *_in, void *_out) nogil:
cdef void _fftw_execute_dft(void *plan, void *_in, void *_out) noexcept nogil:
fftw_execute_dft(<fftw_plan>plan, <fftw_complex *>_in, <fftw_complex *>_out)

cdef void _fftw_execute_dft_r2c(void *plan, void *_in, void *_out) nogil:
cdef void _fftw_execute_dft_r2c(void *plan, void *_in, void *_out) noexcept nogil:
fftw_execute_dft_r2c(<fftw_plan>plan, <fftw_real *>_in, <fftw_complex *>_out)

cdef void _fftw_execute_dft_c2r(void *plan, void *_in, void *_out) nogil:
cdef void _fftw_execute_dft_c2r(void *plan, void *_in, void *_out) noexcept nogil:
fftw_execute_dft_c2r(<fftw_plan>plan, <fftw_complex *>_in, <fftw_real *>_out)

cdef void _fftw_execute_r2r(void *plan, void *_in, void *_out) nogil:
cdef void _fftw_execute_r2r(void *plan, void *_in, void *_out) noexcept nogil:
fftw_execute_r2r(<fftw_plan>plan, <fftw_real *>_in, <fftw_real *>_out)

cdef generic_function _get_execute_function(kind):
Expand Down
2 changes: 1 addition & 1 deletion mpi4py_fft/fftw/utilities.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cython: language_level=3
#cython: language_level=3str

cimport numpy as np
import numpy as np
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools >= 42", "numpy", "cython >= 0.29.32"]
build-backend = "setuptools.build_meta"
Loading
Loading