Skip to content

Commit 7717220

Browse files
jhaleclaude
andcommitted
Convert dev-only extras to PEP 735 dependency groups
Move build/docs/lint/mypy/test/ci from optional-dependencies to dependency-groups, keeping demo/optional/petsc4py as real extras since they are user-facing runtime features or (test) installed against built wheels. Update CI workflows and Dockerfiles to use `pip install --group` instead of `.[...]`, and replace the scikit_build_core.build requires trick with the new `build` group. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 0d03e5c commit 7717220

11 files changed

Lines changed: 55 additions & 51 deletions

File tree

.github/workflows/build-wheels.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ jobs:
271271
wheel pack {dest_dir}/unpacked/* -d {dest_dir} &&
272272
pipx run abi3audit --verbose --strict --report {wheel}
273273
CIBW_TEST_REQUIRES: pytest-xdist
274-
CIBW_TEST_EXTRAS: test
274+
CIBW_TEST_GROUPS: test
275275
CIBW_TEST_COMMAND_LINUX: >
276276
. /etc/profile &&
277277
module load mpi/mpich-$(arch) &&
@@ -313,7 +313,7 @@ jobs:
313313
sudo git clean -fdx && cd ../ &&
314314
docker run -v $(pwd)/dolfinx:/dolfinx -v $(pwd)/simple:/shared \
315315
--env PIP_INDEX_URL=file:///shared --env PIP_EXTRA_INDEX_URL=https://pypi.org/simple python:3.13 \
316-
/bin/bash -l -c "pip install mpich fenics-dolfinx[test] && mpiexec -n 2 python -m pytest -m 'not adios2 and not petsc4py' /dolfinx/python/test/unit"
316+
/bin/bash -l -c "pip install --group /dolfinx/python/pyproject.toml:test mpich fenics-dolfinx && mpiexec -n 2 python -m pytest -m 'not adios2 and not petsc4py' /dolfinx/python/test/unit"
317317
318318
- name: Test in clean python image with pypi Intel MPI (x86_64 only)
319319
if: runner.os == 'Linux' && runner.arch == 'X64'
@@ -322,15 +322,15 @@ jobs:
322322
sudo git clean -fdx && cd ../ &&
323323
docker run -v $(pwd)/dolfinx:/dolfinx -v $(pwd)/simple:/shared \
324324
--env PIP_INDEX_URL=file:///shared --env PIP_EXTRA_INDEX_URL=https://pypi.org/simple python:3.14 \
325-
/bin/bash -l -c "pip install impi-rt fenics-dolfinx[test] && mpiexec -n 2 python -m pytest -m 'not adios2 and not petsc4py' /dolfinx/python/test/unit"
325+
/bin/bash -l -c "pip install --group /dolfinx/python/pyproject.toml:test impi-rt fenics-dolfinx && mpiexec -n 2 python -m pytest -m 'not adios2 and not petsc4py' /dolfinx/python/test/unit"
326326
327327
- name: Test in clean virtual environment with pypi OpenMPI (macOS)
328328
if: runner.os == 'macOS'
329329
run: |
330330
cd dolfinx && git clean -fdx && cd ../
331331
python -m venv venv-test
332332
source venv-test/bin/activate
333-
PIP_EXTRA_INDEX_URL="file://${GITHUB_WORKSPACE}/simple" pip install openmpi fenics-dolfinx[test]
333+
PIP_EXTRA_INDEX_URL="file://${GITHUB_WORKSPACE}/simple" pip install --group dolfinx/python/pyproject.toml:test openmpi fenics-dolfinx
334334
which mpiexec
335335
mpiexec -n 2 python -m pytest -m "not adios2 and not petsc4py" dolfinx/python/test/unit
336336

.github/workflows/ccpp.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: cat .github/workflows/fenicsx-refs.env >> $GITHUB_ENV
4141

4242
- name: Install linting tools
43-
run: pip install clang-format gersemi ruff
43+
run: pip install --group python/pyproject.toml:lint clang-format
4444
- name: ruff .py files in C++ code
4545
run: |
4646
cd cpp/
@@ -96,8 +96,7 @@ jobs:
9696
- name: Install Python build dependencies
9797
working-directory: python
9898
run: |
99-
pip install scikit-build-core setuptools
100-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
99+
pip install --group pyproject.toml:build setuptools
101100
102101
- name: Install UFL
103102
run: |
@@ -151,7 +150,7 @@ jobs:
151150

152151
- name: Build Python interface
153152
run: >
154-
pip install 'python/[test]'
153+
pip install --group python/pyproject.toml:test 'python/'
155154
--check-build-dependencies
156155
--no-build-isolation
157156
--config-settings=cmake.build-type="Developer"
@@ -208,8 +207,7 @@ jobs:
208207
- name: Install Python build dependencies
209208
working-directory: python
210209
run: |
211-
pip install scikit-build-core
212-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
210+
pip install --group pyproject.toml:build
213211
214212
- name: Install UFL
215213
run: |
@@ -265,7 +263,7 @@ jobs:
265263

266264
- name: Build Python interface
267265
run: >
268-
pip install 'python/[test]'
266+
pip install --group python/pyproject.toml:test 'python/'
269267
--check-build-dependencies
270268
--no-build-isolation
271269
--config-settings=cmake.build-type="Developer"
@@ -319,8 +317,7 @@ jobs:
319317
- name: Install Python build dependencies
320318
working-directory: python
321319
run: |
322-
pip install scikit-build-core setuptools
323-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
320+
pip install --group pyproject.toml:build setuptools
324321
325322
- name: Install FEniCS Python components
326323
run: |
@@ -336,7 +333,7 @@ jobs:
336333
337334
- name: Build Python interface
338335
run: >
339-
pip install 'python/[docs]'
336+
pip install --group python/pyproject.toml:docs 'python/'
340337
--check-build-dependencies
341338
--no-build-isolation
342339

.github/workflows/macos.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ jobs:
134134
working-directory: python
135135
run: |
136136
pip install pyamg
137-
pip install scikit-build-core
138-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
139-
pip install --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Developer" './[test]'
137+
pip install --group pyproject.toml:build
138+
pip install --group pyproject.toml:test --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Developer" '.'
140139
141140
- name: Basic test
142141
run: |

.github/workflows/windows.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,12 @@ jobs:
150150
- name: Install DOLFINx Python build dependencies
151151
working-directory: dolfinx-src/python
152152
run: |
153-
pip install scikit-build-core
154-
python -m pip install (python -m scikit_build_core.build requires | Out-String | ConvertFrom-Json)
153+
pip install --group pyproject.toml:build
155154
156155
- name: Install DOLFINx (Python)
157156
working-directory: dolfinx-src/python
158157
run: |
159-
pip -v install --check-build-dependencies --no-build-isolation .[test] --config-settings=cmake.build-type="Release" --config-settings=cmake.args=-DBasix_DIR="D:/a/dolfinx/basix-install/lib/cmake/basix" --config-settings=cmake.args=-Dufcx_DIR="D:/a/dolfinx/ufcx-install/share/ufcx/cmake" --config-settings=cmake.args=-DDOLFINX_DIR="D:/a/dolfinx/dolfinx-install/lib/cmake/dolfinx" --config-settings=cmake.args=-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" --config-settings=cmake.args=-DVCPKG_OVERLAY_PORTS="../cpp/.vcpkg-overlay"
158+
pip -v install --group pyproject.toml:test --check-build-dependencies --no-build-isolation . --config-settings=cmake.build-type="Release" --config-settings=cmake.args=-DBasix_DIR="D:/a/dolfinx/basix-install/lib/cmake/basix" --config-settings=cmake.args=-Dufcx_DIR="D:/a/dolfinx/ufcx-install/share/ufcx/cmake" --config-settings=cmake.args=-DDOLFINX_DIR="D:/a/dolfinx/dolfinx-install/lib/cmake/dolfinx" --config-settings=cmake.args=-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" --config-settings=cmake.args=-DVCPKG_OVERLAY_PORTS="../cpp/.vcpkg-overlay"
160159
161160
- name: Run tests, skip test_mixed_topology_partitioning (Python, serial)
162161
working-directory: dolfinx-src/python/test

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ disclosure process.
262262
for parallel-aware tests where relevant.
263263
- Run the relevant formatter/linter and the affected test suite before
264264
calling a change done — don't rely on CI to catch formatting.
265+
- Dependency groups (`build`, `docs`, `lint`, `mypy`, `test`, `ci` in
266+
`python/pyproject.toml`) use PEP 735 syntax and require `pip >= 25.1`
267+
(or another PEP 735-compliant build frontend) for the `--group` flag.
268+
`demo`, `optional`, and `petsc4py` remain real
269+
`[project.optional-dependencies]` extras since they are user-facing
270+
runtime features, or (in the case of `test`) are installed against
271+
built wheels where dependency groups are unavailable.
265272

266273
## Verifying changes locally
267274

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ To install the Python interface, first install the C++ core, and then in
4545
the `python/` directory run:
4646

4747
```shell
48-
pip install scikit-build-core
49-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
48+
pip install --group pyproject.toml:build
5049
pip install --check-build-dependencies --no-build-isolation .
5150
```
5251

docker/Dockerfile.end-user

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ ONBUILD COPY dolfinx/docker/ffcx_options.json /root/.config/ffcx/ffcx_options.js
6767
# CMake build type for DOLFINx C++ build. See CMake documentation.
6868
ONBUILD ARG DOLFINX_CMAKE_BUILD_TYPE="Release"
6969

70-
# Using pip install `.[test]` with --no-dependencies and --no-build-isolation
71-
# does not install necessary packages, hence install build and optional
72-
# dependencies manually here.
70+
# --no-build-isolation means build dependencies (the `build` dependency
71+
# group in pyproject.toml) are not installed automatically; also install
72+
# the packages needed for testing and optional features here.
7373
ONBUILD RUN cd dolfinx/python && \
74-
pip install --no-cache-dir scikit-build-core && \
75-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install --no-cache-dir && \
74+
pip install --no-cache-dir --group pyproject.toml:build && \
7675
pip install --no-cache-dir pyamg pytest scipy matplotlib numba # test + optional set
7776

7877
# The dolfinx-onbuild container expects to have folders basix/ ufl/

python/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Below is guidance for building the DOLFINx Python interface.
66

77
2. Ensure the Python interface build requirements are installed:
88

9-
pip install scikit-build-core
10-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
9+
pip install --group pyproject.toml:build
1110

1211
3. Build DOLFINx Python interface:
1312

@@ -21,9 +20,9 @@ Note that Developer mode is significantly stricter than CMake's default Debug mo
2120

2221
# Type checking with mypy
2322

24-
1. Install DOLFINx Python with the `[mypy]` optional dependencies set, e.g.:
23+
1. Install DOLFINx Python with the `mypy` dependency group, e.g.:
2524

26-
pip install .[mypy]
25+
pip install --group mypy .
2726

2827
2. Check with mypy, e.g.:
2928

python/doc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
To build the documentation:
44

5-
1. Install DOLFINx Python interface using the ``docs`` optional dependency set, e.g.
5+
1. Install DOLFINx Python interface using the ``docs`` dependency group, e.g.
66

7-
python -m pip install .[docs]
7+
python -m pip install --group docs .
88

99
It must be possible to import the module ``dolfinx`` to build the documentation.
1010

python/doc/source/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Python
120120
After installation of the C++ interface, from the ``python/`` directory
121121
the Python interface can be installed using::
122122

123-
python -m scikit_build_core.build requires | python -c "import sys, json; print(' '.join(json.load(sys.stdin)))" | xargs pip install
123+
pip install --group pyproject.toml:build
124124
pip install --check-build-dependencies --no-build-isolation .
125125

126126

0 commit comments

Comments
 (0)