diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..c868d566 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,96 @@ +name: Testing + +# Trigger the workflow on push or pull request, +# but only for the master branch +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + strategy: + # Don't immediately kill all if one Python version fails + fail-fast: false + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + env: + CC: mpicc + PETSC_DIR: ${{ github.workspace }}/petsc + PETSC_ARCH: default + PETSC_CONFIGURE_OPTIONS: --with-debugging=1 --with-shared-libraries=1 --with-c2html=0 --with-fortran-bindings=0 + RDMAV_FORK_SAFE: 1 + timeout-minutes: 60 + + steps: + - name: Install system dependencies + shell: bash + run: | + sudo apt update + sudo apt install build-essential mpich libmpich-dev \ + libblas-dev liblapack-dev gfortran + + - name: Set correct Python version + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Clone PETSc + uses: actions/checkout@v4 + with: + repository: firedrakeproject/petsc + path: ${{ env.PETSC_DIR }} + + - name: Build and install PETSc + shell: bash + working-directory: ${{ env.PETSC_DIR }} + run: | + ./configure ${PETSC_CONFIGURE_OPTIONS} + make + + - name: Build and install petsc4py + # Remove this step when Firedrake PETSc branch is updated to support + # building petsc4py with Cython>=3.0 + shell: bash + working-directory: ${{ env.PETSC_DIR }}/src/binding/petsc4py + run: | + pip install --upgrade pip + pip install --upgrade wheel 'cython<3' numpy + pip install --no-deps . + + - name: Checkout pyop3 + uses: actions/checkout@v4 + with: + path: pyop3 + + - name: Install pyop3 and testing dependencies + shell: bash + working-directory: pyop3 + run: | + # Gross: + pip install toml + python scripts/requirements.py build | pip install -r /dev/stdin + pip install --no-build-isolation . + python scripts/requirements.py run | pip install -r /dev/stdin + pip install pytest pytest-cov pytest-timeout pytest-xdist pytest-timeout + + - name: Run tests + shell: bash + working-directory: pyop3 + run: | + pytest \ + --durations=200 \ + --tb=native \ + --cov pyop3 \ + --timeout=480 \ + --timeout-method=thread \ + -o faulthandler_timeout=540 \ + -n 12 --dist worksteal \ + -v tests + timeout-minutes: 10 + + diff --git a/pyop3/config.py b/pyop3/config.py index 29f14313..d5758e21 100644 --- a/pyop3/config.py +++ b/pyop3/config.py @@ -36,8 +36,6 @@ import os from tempfile import gettempdir -from loopy.target.c import CWithGNULibcTarget - class ConfigurationError(RuntimeError): pass @@ -155,5 +153,3 @@ def __setitem__(self, key, value): config = Configuration() - -target = CWithGNULibcTarget() diff --git a/pyproject.toml b/pyproject.toml index a6baa300..35ad9086 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,10 @@ [build-system] -requires = ["setuptools", "cython"] +requires = [ + "setuptools", + "cython<3", + "numpy", + "petsc4py" +] build-backend = "setuptools.build_meta" [project] @@ -7,6 +12,10 @@ name = "pyop3" version = "0.1" dependencies = [ "pyrsistent", + "numpy", + "loopy @ git+https://github.com/firedrakeproject/loopy.git", + "mpi4py", + "petsc4py" ] [project.optional-dependencies] diff --git a/scripts/requirements.py b/scripts/requirements.py new file mode 100644 index 00000000..a0f85aea --- /dev/null +++ b/scripts/requirements.py @@ -0,0 +1,11 @@ +import sys + +import toml + +pyproject = toml.load("pyproject.toml") +if "build" in sys.argv: + packages = pyproject["build-system"]["requires"] +elif "run" in sys.argv: + packages = pyproject["project"]["dependencies"] + +print("\n".join([pkg for pkg in packages if pkg != "petsc4py"]))