Skip to content

Commit 323fcc9

Browse files
authored
chore: use dependency-groups (#973)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent df21e44 commit 323fcc9

15 files changed

+101
-94
lines changed

.github/CONTRIBUTING.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ package is in a virtual environment. This is how you would set one up with
5757
Python's built-in venv:
5858

5959
```bash
60-
python3 -m venv .env
61-
source ./.env/bin/activate
62-
pip install -U pip
63-
pip install -ve .[all]
60+
python3 -m venv .venv
61+
source ./.venv/bin/activate
62+
pip install dependency-groups
63+
pip-install-dependency-groups dev
64+
pip install -ve.
6465
```
6566

6667
<details><summary>Optional: External Jupyter kernel (click to expand)</summary>
@@ -109,7 +110,8 @@ Here is the recommendation for a CMake install:
109110
```bash
110111
python3 -m venv env_cmake
111112
source ./env_cmake/bin/activate
112-
pip install -r dev-requirements.txt
113+
pip install dependency-groups
114+
pip-install-dependency-groups dev
113115
cmake -S . -B build-debug \
114116
-GNinja \
115117
-DCMAKE_INSTALL_PREFIX=$(python -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False))")
@@ -285,7 +287,8 @@ This requires LLVM 9+, and is based on [this post](https://aras-p.info/blog/2019
285287
brew install llvm # macOS way to get clang-9
286288
python3 -m venv .env_core # general environment (no install will be made)
287289
. .env_core/bin/activate
288-
pip install -r dev-requirements.txt
290+
pip install dependency-groups
291+
pip-install-dependency-groups dev
289292
CXX="/usr/local/opt/llvm/bin/clang++" cmake -S . -B build-llvm \
290293
-DCMAKE_CXX_FLAGS="-ftime-trace" \
291294
-DPYTHON_EXECUTABLE=$(which python)

.github/workflows/examples.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- "examples/*.py"
88
- "notebooks/*.ipynb"
9+
- ".github/workflows/examples.yml"
910
push:
1011
branches:
1112
- master
@@ -21,13 +22,10 @@ jobs:
2122
- uses: actions/setup-python@v5
2223
with:
2324
python-version: "3.9"
24-
- name: Pre-install NumPy
25-
run: python -m pip install -r dev-requirements.txt nbconvert ipykernel
26-
- name: Install kernel
27-
run: python -m ipykernel install --user --name boost-hist
28-
- name: Build
29-
run: python -m pip install .[examples]
25+
- uses: astral-sh/setup-uv@v4
26+
- name: Build and install kernel
27+
run: uv run --group examples -m ipykernel install --user --name boost-hist
3028
- name: Examples
31-
run: for f in examples/*.py; do python "$f"; done
29+
run: for f in examples/*.py; do uv run "$f"; done
3230
- name: Notebooks
33-
run: jupyter nbconvert --execute --ExecutePreprocessor.timeout=90 --inplace notebooks/*.ipynb
31+
run: uv run jupyter nbconvert --execute --ExecutePreprocessor.timeout=90 --inplace notebooks/*.ipynb

.github/workflows/tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,18 @@ jobs:
7878

7979
- uses: rui314/setup-mold@v1
8080

81-
- uses: yezz123/setup-uv@v4
81+
- uses: astral-sh/setup-uv@v4
8282

8383
- uses: hendrikmuhs/[email protected]
8484
with:
8585
key: ${{ matrix.python-version }}
8686
create-symlink: true
8787

88+
- name: Make requirements.txt
89+
run: |
90+
uv pip install --system dependency-groups
91+
dependency-groups dev > dev-requirements.txt
92+
8893
- name: Install python tools
8994
run: uv pip install --system -r dev-requirements.txt pytest-github-actions-annotate-failures
9095
env:

.github/workflows/weekly.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ jobs:
2121

2222
- uses: actions/setup-python@v5
2323
with:
24-
python-version: "3.11"
24+
python-version: "3.12"
2525

2626
- name: Build and install wheel
27-
run: pip install -v .[test]
27+
run: |
28+
pip install dependency-groups
29+
pip-install-dependency-groups test
30+
pip install -v .
2831
2932
- name: Test
3033
run: python -m pytest

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ repos:
2121
- id: debug-statements
2222
- id: end-of-file-fixer
2323
- id: mixed-line-ending
24-
- id: requirements-txt-fixer
2524
- id: trailing-whitespace
2625

2726
- repo: https://github.com/cheshirekow/cmake-format-precommit
@@ -54,7 +53,7 @@ repos:
5453
rev: v2.3.0
5554
hooks:
5655
- id: codespell
57-
args: ["-L", "hist,nd,circularly,ba", "-w"]
56+
args: ["-L", "hist,nd,circularly,ba,fo", "-w"]
5857
exclude: ^(notebooks/xarray.ipynb|notebooks/BoostHistogramHandsOn.ipynb|.*\.svg)$
5958

6059
- repo: local

.readthedocs.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,14 @@
66
version: 2
77

88
build:
9-
os: ubuntu-22.04
9+
os: "ubuntu-22.04"
1010
tools:
11-
python: "3"
12-
13-
# Build documentation in the docs/ directory with Sphinx
14-
sphinx:
15-
configuration: docs/conf.py
16-
17-
# Include PDF and ePub
18-
formats: all
19-
20-
python:
21-
install:
22-
- requirements: docs/requirements.txt
11+
python: "3.12"
12+
commands:
13+
- asdf plugin add uv
14+
- asdf install uv latest
15+
- asdf global uv latest
16+
- uv run --only-group docs sphinx-build -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
2317

2418
submodules:
2519
exclude: all

dev-requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/conf.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# documentation root, use os.path.abspath to make it absolute, like shown here.
99
#
1010
import contextlib
11+
import importlib.metadata
1112
import shutil
1213
import sys
1314
from pathlib import Path
@@ -31,11 +32,8 @@
3132
copyright = "2020, Henry Schreiner, Hans Dembinski"
3233
author = "Henry Schreiner, Hans Dembinski"
3334

34-
# It is better to use pkg_resources, but we can't build on RtD
35-
from pkg_resources import DistributionNotFound, get_distribution
36-
37-
with contextlib.suppress(DistributionNotFound):
38-
version = get_distribution("boost_histogram").version
35+
with contextlib.suppress(ModuleNotFoundError):
36+
version = importlib.metadata.version("boost_histogram")
3937
# passed if no version (latest/git hash)
4038

4139

docs/requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

notebooks/PerformanceComparison.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
"name": "python",
395395
"nbconvert_exporter": "python",
396396
"pygments_lexer": "ipython3",
397-
"version": "3.7.6"
397+
"version": "3.12.8"
398398
}
399399
},
400400
"nbformat": 4,

0 commit comments

Comments
 (0)