Skip to content

Commit

Permalink
Add pip macOS action
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjward committed Nov 29, 2024
1 parent 36b542a commit 79f37da
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test MacOS
name: Install and test Firedrake (macOS)

on:
push:
Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/pip-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Pip install Firedrake (macOS)

on:
push:
branches:
- master
pull_request:
# By default this workflow is run on the "opened", "synchronize" and
# "reopened" events. We add "labelled" so it will run if the PR is given a label.
types: [opened, synchronize, reopened, labeled]

concurrency:
# Cancels jobs running if new commits are pushed
group: >
${{ github.workflow }}-
${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: "Build Firedrake using pip (macOS)"
runs-on: [self-hosted, macOS]
# Only run this action if we are pushing to master or the PR is labelled "macOS"
if: ${{ (github.ref == 'refs/heads/master') || contains(github.event.pull_request.labels.*.name, 'macOS') }}
env:
OMP_NUM_THREADS: 1
OPENBLAS_NUM_THREADS: 1
steps:
- name: Cleanup
if: ${{ always() }}
run: rm -rf pip_venv

- name: Add homebrew to PATH
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
run: echo "/opt/homebrew/bin" >> "$GITHUB_PATH"

- name: Install homebrew packages
run: brew install gcc autoconf pkg-config make automake cmake ninja libtool boost openblas python python-setuptools mpich

- name: Install PETSc
run: |
git clone https://github.com/firedrakeproject/petsc.git
cd petsc
./configure PETSC_DIR="$PWD" PETSC_ARCH=default \
--with-shared-libraries=1 \
--with-mpi-dir="$(brew --prefix)" \
--with-zlib \
--download-hdf5 \
--download-hwloc \
--download-hypre \
--download-metis \
--download-mumps \
--download-netcdf \
--download-pastix \
--download-pnetcdf \
--download-ptscotch \
--download-scalapack \
--download-suitesparse \
--download-superlu_dist
make
- name: Create a venv
run: |
"$(brew --prefix)/bin/python3" -m venv pip_venv
ln -s /__w/firedrake/firedrake/src pip_venv/
- name: Install libsupermesh
run: |
source pip_venv/bin/activate
python -m pip install 'rtree>=1.2'
cd pip_venv/src
git clone https://github.com/firedrakeproject/libsupermesh.git
mkdir -p libsupermesh/build
cd libsupermesh/build
cmake .. \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="$VIRTUAL_ENV" \
-DMPI_C_COMPILER="$MPICH_DIR/mpicc" \
-DMPI_CXX_COMPILER="$MPICH_DIR/mpicxx" \
-DMPI_Fortran_COMPILER="$MPICH_DIR/mpif90" \
-DCMAKE_Fortran_COMPILER="$MPICH_DIR/mpif90" \
-DMPIEXEC_EXECUTABLE="$MPICH_DIR/mpiexec"
make
make install
- uses: actions/checkout@v4
with:
path: src/firedrake

- name: Pip install
run: |
export PETSC_DIR="$PWD"/petsc
export PETSC_ARCH=default
source pip_venv/bin/activate
cd pip_venv/src
export CC=/opt/homebrew/bin/mpicc
export CXX=opt/homebrew/bin/mpicxx
export MPICC="$CC"
pip install \
--log=firedrake-install.log \
--no-binary mpi4py,h5py \
-v -e './firedrake[test]'
- name: Add mpiexec to the venv and install timeout
run: |
source pip_venv/bin/activate
cat << EOF > "$VIRTUAL_ENV/bin/mpiexec"
#!/bin/bash
"$MPICH_DIR"/mpiexec "\$@"
EOF
chmod +x "$VIRTUAL_ENV"/bin/mpiexec
pip install -U pytest-timeout
- name: Run Firedrake smoke tests
run: |
source pip_venv/bin/activate
cd pip_venv/src/firedrake
pytest -v tests/firedrake/test_0init.py
pytest \
--durations=200 \
--timeout=1800 \
--timeout-method=thread \
-o faulthandler_timeout=1860 \
-n 12 --dist worksteal \
--junit-xml=firedrake.xml \
-sv tests/firedrake/regression -k "poisson_strong or stokes_mini or dg_advection"
timeout-minutes: 120

- name: Cleanup
# Belt and braces: clean up before and after the run.
if: ${{ always() }}
run: rm -rf pip_venv
4 changes: 2 additions & 2 deletions docs/source/download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ type::

You should now be able to run ``firedrake-update``.

Installing Firedrake with pip (experimental, Linux only)
Installing Firedrake with pip (experimental)
--------------------------------------------------------

Firedrake has experimental support for installing using ``pip``, avoiding the need for the ``firedrake-install`` script. At present only Linux is tested using this install method.
Firedrake has experimental support for installing using ``pip``, avoiding the need for the ``firedrake-install`` script.

Requirements
~~~~~~~~~~~~
Expand Down

0 comments on commit 79f37da

Please sign in to comment.