Skip to content

Commit 61077a0

Browse files
committed
Use UV with Nox
1 parent c9549ac commit 61077a0

9 files changed

+413
-246
lines changed

.github/workflows/constraints.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
nox==2024.10.9
12
pip==24.3.1
23
virtualenv==20.29.0

.github/workflows/release-dev.yml

-42
This file was deleted.

.github/workflows/release.yml

+23-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,31 @@ jobs:
3333
pip install --constraint=.github/workflows/hatch-constraints.txt hatch
3434
hatch --version
3535
36+
- name: Check if there is a parent commit
37+
id: check-parent-commit
38+
run: |
39+
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
40+
41+
- name: Detect and tag new version
42+
id: check-version
43+
if: steps.check-parent-commit.outputs.sha
44+
uses: salsify/action-detect-and-tag-new-version@v2
45+
with:
46+
version-command: |
47+
bash -o pipefail -c "hatch version"
48+
49+
- name: Bump version for developmental release
50+
if: "! steps.check-version.outputs.tag"
51+
run: |
52+
version=$(hatch version) &&
53+
hatch version $version.dev.$(date +%s)
54+
55+
- name: Install UV
56+
uses: astral-sh/setup-uv@v5
57+
3658
- name: Build package
3759
run: |
38-
hatch build
60+
uv build
3961
4062
- name: Publish package on PyPI
4163
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

+8-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
matrix:
1414
include:
1515
- { python: "3.13", os: "ubuntu-latest", session: "pre-commit" }
16-
- { python: "3.13", os: "ubuntu-latest", session: "safety" }
1716
- { python: "3.13", os: "ubuntu-latest", session: "mypy" }
1817
- { python: "3.12", os: "ubuntu-latest", session: "mypy" }
1918
- { python: "3.11", os: "ubuntu-latest", session: "mypy" }
@@ -44,10 +43,8 @@ jobs:
4443
pip install --constraint=.github/workflows/constraints.txt pip
4544
pip --version
4645
47-
- name: Install Hatch
48-
run: |
49-
pipx install --pip-args=--constraint=.github/workflows/hatch-constraints.txt hatch
50-
hatch --version
46+
- name: Install UV
47+
uses: astral-sh/setup-uv@v5
5148

5249
- name: Compute pre-commit cache key
5350
if: matrix.session == 'pre-commit'
@@ -73,9 +70,9 @@ jobs:
7370
restore-keys: |
7471
${{ steps.pre-commit-cache.outputs.result }}-
7572
76-
- name: Run Hatch
73+
- name: Run Nox
7774
run: |
78-
hatch run +python=${{ matrix.python }} sessions:run-${{ matrix.session }}
75+
nox --force-color --python=${{ matrix.python }}
7976
8077
- name: Upload coverage data
8178
if: always() && matrix.session == 'tests' && matrix.os == 'ubuntu-latest'
@@ -109,10 +106,8 @@ jobs:
109106
pip install --constraint=.github/workflows/constraints.txt pip
110107
pip --version
111108
112-
- name: Install Hatch
113-
run: |
114-
pipx install --pip-args=--constraint=.github/workflows/hatch-constraints.txt hatch
115-
hatch --version
109+
- name: Install UV
110+
uses: astral-sh/setup-uv@v5
116111

117112
- name: Download coverage data
118113
uses: actions/download-artifact@v4
@@ -125,11 +120,11 @@ jobs:
125120
mv coverage-data-3.11-ubuntu-latest/* .
126121
mv coverage-data-3.10-ubuntu-latest/* .
127122
mv coverage-data-3.9-ubuntu-latest/* .
128-
hatch run coverage:run
123+
nox --force-color --session=coverage
129124
130125
- name: Create coverage report
131126
run: |
132-
hatch run coverage:run-xml
127+
nox --force-color --session=coverage -- xml
133128
134129
- name: Upload coverage report
135130
uses: codecov/codecov-action@v5

CONTRIBUTING.md

+13-26
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,29 @@ Request features on the [Issue Tracker].
3939

4040
You need Python 3.9+ and the following tools:
4141

42-
- [Hatch]
42+
- [UV]
4343

4444
Install the package with development requirements:
4545

46-
```console
47-
$ hatch env create
46+
```sh
47+
$ uv sync --all-extras --frozen
4848
```
4949

50-
You can now run an interactive Python session:
51-
52-
```console
53-
$ hatch shell
54-
import human_readable
55-
```
56-
57-
[hatch]: https://hatch.pypa.io/
50+
[uv]: https://docs.astral.sh/uv/
5851

5952
## How to test the project
6053

6154
Run the full test suite:
6255

63-
```console
64-
$ hatch run all
65-
```
66-
67-
List the available Hatch env scripts:
68-
69-
```console
70-
$ hatch env show
56+
```sh
57+
$ uv run nox
7158
```
7259

73-
You can run a specific Hatch env script.
60+
You can run a specific Nox session.
7461
For example, invoke the unit test suite like this:
7562

76-
```console
77-
$ hatch run tests:run
63+
```sh
64+
$ uv run nox -s tests
7865
```
7966

8067
Unit tests are located in the `tests` directory,
@@ -84,13 +71,13 @@ and are written using the [pytest] testing framework.
8471

8572
Make sure you have installed a PO Editor, you can easily install that on a Debian-based system with:
8673

87-
```console
74+
```sh
8875
apt install poedit
8976
```
9077

9178
To add a new locale you need to execute:
9279

93-
```console
80+
```sh
9481
xgettext --from-code=UTF-8 -o human_readable.pot -k'_' -k'N_' -k'P_:1c,2' -l python src/human_readable/*.py # extract new phrases
9582
msginit -i human_readable.pot -o human_readable/locale/<locale name>/LC_MESSAGES/human_readable.po --locale <locale name>
9683
```
@@ -99,7 +86,7 @@ Then edit your .po file in the locale folder that got created.
9986

10087
If possible, add tests to `tests/functional/new_locale`. Run them with:
10188

102-
```console
89+
```sh
10390
nox -s tests
10491
```
10592

@@ -117,7 +104,7 @@ Feel free to submit early, though—we can always iterate on this.
117104

118105
To run linting and code formatting checks before commiting your change, you can install pre-commit as a Git hook by running the following command:
119106

120-
```console
107+
```sh
121108
$ nox --session=pre-commit -- install
122109
```
123110

codecov.yml

-9
This file was deleted.

0 commit comments

Comments
 (0)