Skip to content

Commit dfc7b06

Browse files
authored
chore: use hatch instead of nox (#212)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent def8168 commit dfc7b06

File tree

6 files changed

+103
-177
lines changed

6 files changed

+103
-177
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "repo-review[dev]",
33
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
4-
"postCreateCommand": "pipx install nox && pip install -e.[cli,test] pylint",
4+
"postCreateCommand": "pipx install hatch && pip install -e.[cli,test] pylint",
55
"customizations": {
66
"vscode": {
77
"extensions": [

.github/CONTRIBUTING.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,32 @@ detailed description of best practices for developing Scikit-HEP packages.
55

66
## Quick development
77

8-
The fastest way to start with development is to use nox. If you don't have nox,
9-
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
10-
If you don't have pipx (pip for applications), then you can install with with
11-
`pip install pipx` (the only case were installing an application with regular
12-
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
13-
`brew install pipx nox`.
8+
The fastest way to start with development is to use hatch. If you don't have
9+
hatch, you can use `pipx run hatch` to run it without installing, or `pipx
10+
install hatch`. If you don't have pipx (pip for applications), then you can
11+
install with with `pip install pipx` (the only case were installing an
12+
application with regular pip is reasonable). If you use macOS, then pipx and
13+
hatch are both in brew, use `brew install pipx hatch`. Hatch 1.10+ is required.
1414

15-
To use, run `nox`. This will lint and test using every installed version of
16-
Python on your system, skipping ones that are not installed. You can also run
17-
specific jobs:
15+
Here are some common tasks you might want to run:
1816

1917
```console
20-
$ nox -s lint # Lint only
21-
$ nox -s tests # Tests
22-
$ nox -s docs -- --serve # Build and serve the docs
23-
$ nox -s build # Make an SDist and wheel
18+
$ hatch run lint:lint # all linters (pre-commit)
19+
$ hatch run pylint:lint # pylint
20+
$ hatch fmt # just format & basic lint
21+
$ hatch tests # run the tests
22+
$ hatch build # build SDist and wheel
23+
$ hatch run docs:serve # build and serve the docs
24+
$ hatch run docs:html # just build the docs
25+
$ hatch run docs:man # build manpage
26+
$ hatch run docs:linkcheck # check for broken links
27+
$ hatch run api-docs:build # rebuild the API docs
28+
$ hatch run webapp:serve # serve the webapp
29+
$ hatch run example:repo-review <args> # Run an example
2430
```
2531

26-
Nox handles everything for you, including setting up an temporary virtual
27-
environment for each run.
28-
29-
You can also use `nox -s run -- .` to run an example set of checks on a repo.
32+
Hatch handles everything for you, including setting up an temporary virtual
33+
environment.
3034

3135
## Setting up a development environment manually
3236

@@ -71,19 +75,25 @@ pytest
7175
You can build the docs using:
7276

7377
```bash
74-
nox -s docs
78+
hatch run docs:docs
7579
```
7680

7781
You can see a preview with:
7882

7983
```bash
80-
nox -s docs -- --serve
84+
hatch run docs:serve
85+
```
86+
87+
You can rebuild the API docs with:
88+
89+
```bash
90+
$ hatch run api-docs:build
8191
```
8292

8393
## Pre-commit
8494

8595
This project uses pre-commit for all style checking. While you can run it with
86-
nox, this is such an important tool that it deserves to be installed on its
96+
hatch, this is such an important tool that it deserves to be installed on its
8797
own. Install pre-commit and run:
8898

8999
```bash
@@ -94,5 +104,5 @@ to check all files.
94104

95105
## Running DevContainer
96106

97-
You can use DevContainer, such as in GitHub Codespaces or locally. Nox and a
107+
You can use DevContainer, such as in GitHub Codespaces or locally. Hatch and a
98108
local install will be available.

.github/workflows/ci.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ jobs:
3232
- name: Run PyLint
3333
run: |
3434
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
35-
pipx run --python=python nox -s pylint
35+
pipx run --python=python hatch run pylint:lint
3636
3737
checks:
38-
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
38+
name: Check Python on ${{ matrix.runs-on }}
3939
runs-on: ${{ matrix.runs-on }}
40-
needs: [pre-commit]
4140
strategy:
4241
fail-fast: false
4342
matrix:
44-
python-version: ["3.10", "3.11", "3.12"]
4543
runs-on: [ubuntu-latest, macos-latest, windows-latest]
4644

4745
steps:
@@ -51,18 +49,19 @@ jobs:
5149

5250
- uses: actions/setup-python@v5
5351
with:
54-
python-version: ${{ matrix.python-version }}
52+
python-version: |
53+
3.10
54+
3.11
55+
3.12
5556
5657
- name: Setup uv
5758
uses: yezz123/setup-uv@v4
58-
with:
59-
uv-venv: ".venv"
6059

61-
- name: Install package
62-
run: uv pip install .[test,cli]
60+
- name: Install hatch
61+
run: uv pip install --system hatch
6362

64-
- name: Test package
65-
run: python -m pytest -ra
63+
- name: Test package (all Pythons)
64+
run: hatch test -a
6665
env:
6766
PYTHONUTF8: "1"
6867

@@ -88,19 +87,22 @@ jobs:
8887
- name: Setup uv
8988
uses: yezz123/setup-uv@v4
9089

91-
- uses: wntrblm/nox@2024.04.15
90+
- uses: actions/setup-python@v5
9291
with:
93-
python-versions: "3.11"
92+
python-version: "3.12"
93+
94+
- name: Install hatch
95+
run: uv pip install --system hatch
9496

9597
- name: Linkcheck
96-
run: nox -s docs -- -b linkcheck
98+
run: hatch run docs:linkcheck
9799

98100
- name: Build docs with warnings as errors
99-
run: nox -s docs -- -W
101+
run: hatch run docs:html -W
100102

101103
- name: Verify no changes required to API docs
102104
run: |
103-
nox -s build_api_docs
105+
hatch run api-docs:build
104106
git diff --exit-code
105107
106108
action:

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,15 @@ repos:
7575
language: pygrep
7676
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
7777
exclude: .pre-commit-config.yaml
78+
79+
- repo: https://github.com/henryiii/validate-pyproject-schema-store
80+
rev: 2024.04.29
81+
hooks:
82+
- id: validate-pyproject
83+
84+
- repo: https://github.com/python-jsonschema/check-jsonschema
85+
rev: 0.28.2
86+
hooks:
87+
- id: check-dependabot
88+
- id: check-github-workflows
89+
- id: check-readthedocs

noxfile.py

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

pyproject.toml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,46 @@ repo-review = "repo_review.schema:get_schema"
8484
version.source = "vcs"
8585
build.hooks.vcs.version-file = "src/repo_review/_version.py"
8686

87+
[tool.hatch.envs.default]
88+
installer = "uv"
89+
90+
[tool.hatch.envs.hatch-test]
91+
features = ["test", "cli"]
92+
93+
[tool.hatch.envs.lint]
94+
dependencies = ["pre-commit"]
95+
skip-install = true
96+
scripts.lint = "pre-commit run --all-files --show-diff-on-failure {args}"
97+
98+
[tool.hatch.envs.pylint]
99+
features = ["cli"]
100+
dependencies = ["pylint"]
101+
scripts.lint = "pylint repo_review {args}"
102+
103+
[tool.hatch.envs.docs]
104+
features = ["docs"]
105+
dependencies = ["sphinx-autobuild"]
106+
scripts.linkcheck = "sphinx-build -b=linkcheck docs docs/_build/linkcheck {args}"
107+
scripts.html = "sphinx-build --keep-going -n -T -b=html docs docs/_build/html {args}"
108+
scripts.serve = "sphinx-autobuild -n -T -b=html docs docs/_build/html {args}"
109+
scripts.man = "sphinx-build --keep-going -n -T -b=man docs docs/_build/man {args}"
110+
111+
[tool.hatch.envs.api-docs]
112+
skip-install = true
113+
dependencies = ["sphinx"]
114+
scripts.build = "sphinx-apidoc -o docs/api/ --module-first --no-toc --force src/repo_review"
115+
116+
[tool.hatch.envs.example]
117+
features = ["cli"]
118+
post-install-commands = ["$HATCH_UV pip install -e tests/test_utilities"]
119+
120+
[tool.hatch.envs.webapp]
121+
skip-install = true
122+
scripts.serve = "cd docs && echo 'Serving on http://localhost:8080' && python -m http.server 8080"
123+
124+
[[tool.hatch.envs.hatch-test.matrix]]
125+
python = ["3.12", "3.11", "3.10"]
126+
87127

88128
[tool.pytest.ini_options]
89129
minversion = "7.0"
@@ -164,7 +204,7 @@ extend-select = [
164204
"YTT", # flake8-2020
165205
]
166206
ignore = [
167-
"ISC001", # May collide with formatter
207+
"ISC001", # May collide with formatter
168208
"PT004", # Incorrect check, usefixtures is the correct way to do this
169209
"PLR09", # Too many X
170210
"PLR2004", # Magic value in comparison

0 commit comments

Comments
 (0)