Skip to content

Commit 2320c9c

Browse files
build: Use dependency groups to define development dependencies (#2616)
* Use dependency-groups table to define development dependencies over extras to avoid distributing collections of tools meant only for local development. - c.f. https://learn.scientific-python.org/development/guides/packaging-simple/#development-dependencies - c.f. https://packaging.python.org/en/latest/specifications/dependency-groups/ * Use 'dev' as development group name to get picked up by uv's high level interface automatically. * Use '--group' syntax with install commands to install requested dependency groups.
1 parent 478e04c commit 2320c9c

File tree

11 files changed

+24
-21
lines changed

11 files changed

+24
-21
lines changed

.github/workflows/ci-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Install dependencies
3434
run: |
3535
python -m pip install uv
36-
uv pip install --system --upgrade '.[all,test]'
36+
uv pip install --system --upgrade '.[all]' --group test
3737
3838
- name: List installed Python packages
3939
run: python -m pip list

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Install dependencies
5050
run: |
5151
python -m pip install uv
52-
uv pip install --system --upgrade ".[all,test]"
52+
uv pip install --system --upgrade ".[all]" --group test
5353
5454
- name: List installed Python packages
5555
run: python -m pip list

.github/workflows/dependencies-head.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install dependencies
3535
run: |
3636
python -m pip install uv
37-
uv pip --no-cache --quiet install --system --upgrade --pre ".[all,test]"
37+
uv pip --no-cache --quiet install --system --upgrade --pre ".[all]" --group test
3838
python -m pip list
3939
4040
- name: List release candidates, alpha, and beta releases
@@ -65,7 +65,7 @@ jobs:
6565
- name: Install dependencies
6666
run: |
6767
python -m pip install uv
68-
uv pip --no-cache --quiet install --system --upgrade ".[all,test]"
68+
uv pip --no-cache --quiet install --system --upgrade ".[all]" --group test
6969
uv pip uninstall --system scipy
7070
# uv wants to upgrade dependencies (numpy) to a dev release too, so don't --upgrade
7171
uv pip install --system --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple scipy
@@ -93,7 +93,7 @@ jobs:
9393
- name: Install dependencies
9494
run: |
9595
python -m pip install uv
96-
uv pip --no-cache --quiet install --system --upgrade ".[all,test]"
96+
uv pip --no-cache --quiet install --system --upgrade ".[all]" --group test
9797
uv pip uninstall --system iminuit
9898
uv pip install --system --upgrade cython
9999
uv pip install --system --upgrade git+https://github.com/scikit-hep/iminuit.git
@@ -120,7 +120,7 @@ jobs:
120120
- name: Install dependencies
121121
run: |
122122
python -m pip install uv
123-
uv pip --no-cache --quiet install --system --upgrade ".[all,test]"
123+
uv pip --no-cache --quiet install --system --upgrade ".[all]" --group test
124124
uv pip uninstall --system uproot
125125
uv pip install --system --upgrade git+https://github.com/scikit-hep/uproot5.git
126126
python -m pip list
@@ -148,7 +148,7 @@ jobs:
148148
- name: Install dependencies
149149
run: |
150150
python -m pip install uv
151-
uv pip --no-cache --quiet install --system --upgrade ".[all,test]"
151+
uv pip --no-cache --quiet install --system --upgrade ".[all]" --group test
152152
uv pip uninstall --system matplotlib
153153
# Need to use --extra-index-url as all dependencies aren't on scientific-python-nightly-wheels package index.
154154
# Need to use --pre as dev releases will need priority over stable releases.
@@ -185,7 +185,7 @@ jobs:
185185
- name: Install dependencies
186186
run: |
187187
python -m pip install uv
188-
uv pip --no-cache --quiet install --system --upgrade ".[all,test]"
188+
uv pip --no-cache --quiet install --system --upgrade ".[all]" --group test
189189
uv pip uninstall --system pytest
190190
uv pip install --system --upgrade git+https://github.com/pytest-dev/pytest.git
191191
python -m pip list

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Install Python dependencies
3333
run: |
3434
python -m pip install uv
35-
uv pip --quiet install --system --upgrade ".[docs,test]"
35+
uv pip --quiet install --system --upgrade . --group docs --group test
3636
uv pip install --system yq
3737
python -m pip list
3838

.github/workflows/lower-bound-requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: |
3232
python -m pip install uv
3333
uv pip install --system --upgrade 'setuptools<70.0.0'
34-
uv pip --no-cache install --system --constraint tests/constraints.txt ".[all,test]"
34+
uv pip --no-cache install --system --constraint tests/constraints.txt ".[all]" --group test
3535
3636
- name: List installed Python packages
3737
run: python -m pip list

.github/workflows/notebooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: |
3434
python -m pip install uv
3535
# FIXME: c.f. https://github.com/scikit-hep/pyhf/issues/2104
36-
uv pip install --system --upgrade ".[all,test]" 'jupyter-client<8.0.0'
36+
uv pip install --system --upgrade ".[all]" --group test 'jupyter-client<8.0.0'
3737
3838
- name: List installed Python packages
3939
run: python -m pip list

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ build:
1919
post_install:
2020
# VIRTUAL_ENV needs to be set manually for now.
2121
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
22-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install '.[docs]'
22+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install . --group docs
2323

2424
# Build documentation in the docs/ directory with Sphinx
2525
sphinx:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ We recommend first reading the "[Developing](https://scikit-hep.org/pyhf/develop
5555
You can install the development environment (which includes a number of extra) libraries and all others needed to run the tests via `pip`:
5656

5757
```console
58-
python -m pip install --upgrade --editable '.[develop]'
58+
python -m pip install --upgrade --editable . --group dev
5959
```
6060

6161
To make the PR process much smoother we also strongly recommend that you setup the Git pre-commit hook for [Black](https://github.com/psf/black) by running

docs/development.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ and install all necessary packages for development
2020

2121
.. code-block:: console
2222
23-
python -m pip install --upgrade --editable '.[develop]'
23+
python -m pip install --upgrade --editable . --group dev
2424
2525
Then setup the Git `pre-commit <https://pre-commit.com/>`__ hooks by running
2626

noxfile.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# Default sessions to run if no session handles are passed
1010
nox.options.sessions = ["lint", "tests-3.13"]
11+
nox.options.default_venv_backend = "uv|virtualenv"
1112

1213

1314
DIR = Path(__file__).parent.resolve()
@@ -35,7 +36,7 @@ def tests(session):
3536
$ nox --session tests --python 3.13 -- tests/test_tensor.py # run specific tests
3637
$ nox --session tests --python 3.13 -- coverage # run with coverage but slower
3738
"""
38-
session.install("--upgrade", "--editable", ".[all,test]")
39+
session.install("--upgrade", "--editable", ".[all]", "--group", "test")
3940
session.install("--upgrade", "pytest")
4041

4142
# Allow tests to be run with coverage
@@ -107,7 +108,7 @@ def regenerate(session):
107108
"""
108109
Regenerate Matplotlib images.
109110
"""
110-
session.install("--upgrade", "--editable", ".[all,test]")
111+
session.install("--upgrade", "--editable", ".[all]", "--group", "test")
111112
session.install("--upgrade", "pytest", "matplotlib")
112113
if not sys.platform.startswith("linux"):
113114
session.error(
@@ -133,7 +134,7 @@ def docs(session):
133134
$ nox --session docs -- serve # Need for local jupyterlite preview
134135
$ nox --session docs -- clean
135136
"""
136-
session.install("--upgrade", "--editable", ".[backends,contrib,docs]")
137+
session.install("--upgrade", "--editable", ".[backends,contrib]", "--group", "docs")
137138
session.install("--upgrade", "sphinx")
138139

139140
build_path = DIR / "docs" / "_build"
@@ -182,7 +183,7 @@ def notebooks(session: nox.Session):
182183
"""
183184
Run the notebook tests.
184185
"""
185-
session.install("--upgrade", "--editable", ".[all,test]")
186+
session.install("--upgrade", "--editable", ".[all]", "--group", "test")
186187
session.run(
187188
"pytest",
188189
"--override-ini",

0 commit comments

Comments
 (0)