Skip to content

Commit

Permalink
Docker simplify (phase 2) (#3232)
Browse files Browse the repository at this point in the history
* Use venv

* Simplify CI steps

* Fixes

* Simplifications
  • Loading branch information
garth-wells committed May 28, 2024
1 parent 5d0a55f commit 9533112
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 49 deletions.
64 changes: 30 additions & 34 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ jobs:
- name: Install Python demo/test dependencies
run: pip install matplotlib pyamg pytest pytest-xdist scipy
- name: Run demos (Python, serial)
run: python3 -m pytest -n auto -m serial --durations=10 python/demo/test.py
run: python -m pytest -n auto -m serial --durations=10 python/demo/test.py
- name: Run demos (Python, MPI (np=3))
run: python3 -m pytest -m mpi --num-proc=3 python/demo/test.py
run: python -m pytest -m mpi --num-proc=3 python/demo/test.py
- name: Run unit tests
run: python -m pytest -n auto -m "not petsc4py and not adios2" python/test/unit
- name: Run unit tests (MPI, np=3)
Expand Down Expand Up @@ -165,26 +165,25 @@ jobs:
- uses: actions/checkout@v4

- name: Install required Python packages (docs)
run: python3 -m pip install --break-system-packages breathe jupytext myst_parser sphinx sphinx_rtd_theme
run: pip install breathe jupytext matplotlib myst_parser sphinx sphinx_rtd_theme

- name: Install FEniCS Python components (default branches/tags)
if: github.event_name != 'workflow_dispatch'
run: |
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ufl.git
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/basix.git
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ffcx.git
pip install git+https://github.com/FEniCS/ufl.git
pip install git+https://github.com/FEniCS/basix.git
pip install git+https://github.com/FEniCS/ffcx.git
- name: Install FEniCS Python components
if: github.event_name == 'workflow_dispatch'
run: |
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_ref }}
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/basix.git@${{ github.event.inputs.basix_ref }}
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ffcx.git@${{ github.event.inputs.ffcx_ref }}
pip install git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_ref }}
pip install git+https://github.com/FEniCS/basix.git@${{ github.event.inputs.basix_ref }}
pip install git+https://github.com/FEniCS/ffcx.git@${{ github.event.inputs.ffcx_ref }}
- name: Configure C++
run: cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build -S cpp/
- name: Build and install C++ library
- name: Configure, build and install C++ library
run: |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build -S cpp/
cmake --build build
cmake --install build
Expand Down Expand Up @@ -217,33 +216,32 @@ jobs:
ctest -V -R demo -R mpi_2
- name: Install required Python (build Python interface)
run: python3 -m pip install --break-system-packages nanobind scikit-build-core[pyproject]
run: pip install nanobind scikit-build-core[pyproject]

- name: Build Python interface
run: |
python3 -m pip install --break-system-packages --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Debug" python/
pip install --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Debug" python/
- name: Build Python interface documentation
run: |
python3 -m pip install --break-system-packages matplotlib
cd python/doc
python3 -m sphinx -W -b html source/ build/html/
python -m sphinx -W -b html source/ build/html/
- name: Set default DOLFINx JIT options
run: |
mkdir -p ~/.config/dolfinx
echo '{ "cffi_extra_compile_args": ["-g0", "-O0" ] }' > ~/.config/dolfinx/dolfinx_jit_options.json
- name: Install Python demo/test dependencies
run: python3 -m pip install --break-system-packages matplotlib numba pyamg pytest pytest-xdist scipy
run: pip install numba pyamg pytest pytest-xdist scipy
- name: Run demos (Python, serial)
run: python3 -m pytest -n auto -m serial --durations=10 python/demo/test.py
run: python -m pytest -n auto -m serial --durations=10 python/demo/test.py
- name: Run demos (Python, MPI (np=3))
run: python3 -m pytest -m mpi --num-proc=3 python/demo/test.py
run: python -m pytest -m mpi --num-proc=3 python/demo/test.py

- name: Run Python unit tests (serial)
run: python3 -m pytest -m "petsc4py or adios2" -n=auto --durations=50 python/test/unit/
run: python -m pytest -m "petsc4py or adios2" -n=auto --durations=50 python/test/unit/
- name: Run Python unit tests (MPI, np=3)
run: mpirun -np 3 python3 -m pytest -m "petsc4py or adios2" python/test/unit/
run: mpirun -np 3 python -m pytest -m "petsc4py or adios2" python/test/unit/

publish-docs:
if: ${{ github.repository == 'FEniCS/dolfinx' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') ) }}
Expand All @@ -260,21 +258,21 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install required Python packages (C++ docs)
run: python3 -m pip install --break-system-packages breathe jupytext myst_parser sphinx sphinx_rtd_theme
- name: Install required Python packages (docs)
run: pip install breathe jupytext matplotlib myst_parser sphinx sphinx_rtd_theme

- name: Install FEniCS Python components (default branches/tags)
if: github.event_name != 'workflow_dispatch'
run: |
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ufl.git
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/basix.git
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ffcx.git
pip install git+https://github.com/FEniCS/ufl.git
pip install git+https://github.com/FEniCS/basix.git
pip install git+https://github.com/FEniCS/ffcx.git
- name: Install FEniCS Python components
if: github.event_name == 'workflow_dispatch'
run: |
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_ref }}
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/basix.git@${{ github.event.inputs.basix_ref }}
python3 -m pip install --break-system-packages git+https://github.com/FEniCS/ffcx.git@${{ github.event.inputs.ffcx_ref }}
pip install git+https://github.com/FEniCS/ufl.git@${{ github.event.inputs.ufl_ref }}
pip install git+https://github.com/FEniCS/basix.git@${{ github.event.inputs.basix_ref }}
pip install git+https://github.com/FEniCS/ffcx.git@${{ github.event.inputs.ffcx_ref }}
- name: Configure C++
run: |
Expand All @@ -291,16 +289,14 @@ jobs:
make html
- name: Install required Python (build Python interface)
run: python3 -m pip install --break-system-packages nanobind scikit-build-core[pyproject]
run: pip install nanobind scikit-build-core[pyproject]

- name: Build Python interface
run: |
python3 -m pip install --break-system-packages --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Debug" python/
run: pip install --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Debug" python/
- name: Build Python interface documentation
run: |
python3 -m pip install --break-system-packages matplotlib
cd python/doc
python3 -m sphinx -W -b html source/ build/html/
python -m sphinx -W -b html source/ build/html/
- name: Checkout FEniCS/docs
uses: actions/checkout@v4
Expand Down
23 changes: 11 additions & 12 deletions docker/Dockerfile.test-env
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
pkg-config \
python3-dev \
python3-pip \
python3-setuptools && \
python3-venv && \
#
apt-get -y install \
catch2 \
Expand Down Expand Up @@ -143,15 +143,14 @@ RUN if [ "$MPI" = "mpich" ]; then \
ldconfig && \
rm -rf /tmp/*

ENV VIRTUAL_ENV /dolfinx-env
ENV PATH /dolfinx-env/bin:$PATH
RUN python3 -m venv ${VIRTUAL_ENV}

# Install Python packages (via pip)
# - make sure pip/setuptoools are up-to-date before using them
# - First set of packages are required to build and run DOLFINx Python.
# - Second set of packages are recommended and/or required to build
# documentation or run tests.
# - Final set of packages are required to build petsc4py
RUN pip3 install --break-system-packages --no-cache-dir --upgrade setuptools pip && \
pip3 install --break-system-packages --no-cache-dir cffi numpy==${NUMPY_VERSION} && \
pip3 install --break-system-packages --no-cache-dir --no-build-isolation mpi4py
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir cffi numpy==${NUMPY_VERSION} setuptools wheel && \
pip install --no-cache-dir --no-build-isolation mpi4py

# Install KaHIP
RUN wget -nc --quiet https://github.com/kahip/kahip/archive/v${KAHIP_VERSION}.tar.gz && \
Expand Down Expand Up @@ -317,8 +316,8 @@ RUN apt-get -qq update && \
make PETSC_ARCH=linux-gnu-complex128-64 ${MAKEFLAGS} all && \
# Install petsc4py
cd src/binding/petsc4py && \
pip3 install --break-system-packages --no-cache-dir cython wheel && \
PETSC_ARCH=linux-gnu-real32-32:linux-gnu-complex64-32:linux-gnu-real64-32:linux-gnu-complex128-32:linux-gnu-real64-64:linux-gnu-complex128-64 pip3 install --break-system-packages --no-cache-dir -v --no-build-isolation . && \
pip install --no-cache-dir cython wheel && \
PETSC_ARCH=linux-gnu-real32-32:linux-gnu-complex64-32:linux-gnu-real64-32:linux-gnu-complex128-32:linux-gnu-real64-64:linux-gnu-complex128-64 pip -v install --no-cache-dir --no-build-isolation . && \
# pip3 uninstall --yes cython wheel && \
# Cleanup
apt-get -y purge bison flex && \
Expand Down Expand Up @@ -361,7 +360,7 @@ RUN git clone --depth=1 -b v${SLEPC_VERSION} https://gitlab.com/slepc/slepc.git
# Install slepc4py
cd src/binding/slepc4py && \
# pip3 install --break-system-packages --no-cache-dir cython wheel && \
PETSC_ARCH=linux-gnu-real32-32:linux-gnu-complex64-32:linux-gnu-real64-32:linux-gnu-complex128-32:linux-gnu-real64-64:linux-gnu-complex128-64 pip3 install --break-system-packages --no-cache-dir --no-build-isolation . && \
PETSC_ARCH=linux-gnu-real32-32:linux-gnu-complex64-32:linux-gnu-real64-32:linux-gnu-complex128-32:linux-gnu-real64-64:linux-gnu-complex128-64 pip -v install --no-cache-dir --no-build-isolation . && \
# pip3 uninstall --yes cython wheel && \
rm -rf ${SLEPC_DIR}/CTAGS ${SLEPC_DIR}/TAGS ${SLEPC_DIR}/docs ${SLEPC_DIR}/src/ ${SLEPC_DIR}/**/obj/ ${SLEPC_DIR}/**/test/ && \
rm -rf /tmp/*
Expand Down
3 changes: 1 addition & 2 deletions python/build-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
nanobind>=2.0.0
scikit-build-core[pyproject]
petsc4py
scikit-build-core[pyproject]>=0.5
mpi4py
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ docs = ["markdown", "pyyaml", "sphinx", "sphinx_rtd_theme"]
lint = ["ruff"]
optional = ["numba"]
petsc4py = ["petsc4py"]
test = ["pytest", "sympy", "scipy", "matplotlib", "fenics-dolfinx[optional]"]
test = ["pytest", "scipy", "matplotlib", "fenics-dolfinx[optional]"]
ci = [
"mypy",
"pytest-xdist",
Expand Down

0 comments on commit 9533112

Please sign in to comment.