Skip to content

Commit 98003f8

Browse files
authored
Merge pull request #614 from 1nv0k32/feature/switch-poetry-to-hatch
Switch from Poetry/Nox to Hatch
2 parents c6d5506 + 54395a8 commit 98003f8

File tree

10 files changed

+189
-1862
lines changed

10 files changed

+189
-1862
lines changed

.github/workflows/constraints.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
pip==23.1.2
2-
nox==2023.4.22
3-
nox-poetry==1.0.2
42
virtualenv==20.23.1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hatch==1.6.3

.github/workflows/poetry-constraints.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
pip install --constraint=.github/workflows/constraints.txt pip
2626
pip --version
2727
28-
- name: Install Poetry
28+
- name: Install Hatch
2929
run: |
30-
pip install --constraint=.github/workflows/poetry-constraints.txt poetry
31-
poetry --version
30+
pip install --constraint=.github/workflows/hatch-constraints.txt hatch
31+
hatch --version
3232
3333
- name: Check if there is a parent commit
3434
id: check-parent-commit
@@ -41,18 +41,17 @@ jobs:
4141
uses: salsify/action-detect-and-tag-new-version@v2
4242
with:
4343
version-command: |
44-
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
44+
bash -o pipefail -c "hatch version"
4545
4646
- name: Bump version for developmental release
4747
if: "! steps.check-version.outputs.tag"
4848
run: |
49-
poetry version patch &&
50-
version=$(poetry version | awk '{ print $2 }') &&
51-
poetry version $version.dev.$(date +%s)
49+
version=$(hatch version) &&
50+
hatch version $version.dev.$(date +%s)
5251
5352
- name: Build package
5453
run: |
55-
poetry build --ansi
54+
hatch build
5655
5756
- name: Publish package on PyPI
5857
if: steps.check-version.outputs.tag

.github/workflows/tests.yml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ jobs:
2828
- { python: "3.11", os: "ubuntu-latest", session: "xdoctest" }
2929
- { python: "3.11", os: "ubuntu-latest", session: "docs-build" }
3030

31-
env:
32-
NOXSESSION: ${{ matrix.session }}
33-
3431
steps:
3532
- name: Check out the repository
3633
uses: actions/checkout@v3
@@ -45,16 +42,10 @@ jobs:
4542
pip install --constraint=.github/workflows/constraints.txt pip
4643
pip --version
4744
48-
- name: Install Poetry
49-
run: |
50-
pipx install --pip-args=--constraint=.github/workflows/poetry-constraints.txt poetry
51-
poetry --version
52-
53-
- name: Install Nox
45+
- name: Install Hatch
5446
run: |
55-
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
56-
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
57-
nox --version
47+
pipx install --pip-args=--constraint=.github/workflows/hatch-constraints.txt hatch
48+
hatch --version
5849
5950
- name: Compute pre-commit cache key
6051
if: matrix.session == 'pre-commit'
@@ -80,12 +71,12 @@ jobs:
8071
restore-keys: |
8172
${{ steps.pre-commit-cache.outputs.result }}-
8273
83-
- name: Run Nox
74+
- name: Run Hatch
8475
run: |
85-
nox --force-color --python=${{ matrix.python }}
76+
hatch run +python=${{ matrix.python }} sessions:run-${{ matrix.session }}
8677
8778
- name: Upload coverage data
88-
if: always() && matrix.session == 'tests'
79+
if: always() && matrix.session == 'tests' && matrix.os == 'ubuntu-latest'
8980
uses: "actions/upload-artifact@v3"
9081
with:
9182
name: coverage-data
@@ -115,16 +106,10 @@ jobs:
115106
pip install --constraint=.github/workflows/constraints.txt pip
116107
pip --version
117108
118-
- name: Install Poetry
119-
run: |
120-
pipx install --pip-args=--constraint=.github/workflows/poetry-constraints.txt poetry
121-
poetry --version
122-
123-
- name: Install Nox
109+
- name: Install Hatch
124110
run: |
125-
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
126-
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
127-
nox --version
111+
pipx install --pip-args=--constraint=.github/workflows/hatch-constraints.txt hatch
112+
hatch --version
128113
129114
- name: Download coverage data
130115
uses: actions/download-artifact@v3
@@ -133,11 +118,11 @@ jobs:
133118

134119
- name: Combine coverage data and display human readable report
135120
run: |
136-
nox --force-color --session=coverage
121+
hatch run coverage:run
137122
138123
- name: Create coverage report
139124
run: |
140-
nox --force-color --session=coverage -- xml
125+
hatch run coverage:run-xml
141126
142127
- name: Upload coverage report
143128
uses: codecov/codecov-action@v3

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ repos:
6060
language: system
6161
types: [text]
6262
stages: [commit, push, manual]
63-
- repo: https://github.com/prettier/pre-commit
63+
- repo: https://github.com/pre-commit/mirrors-prettier
6464
rev: v2.1.2
6565
hooks:
6666
- id: prettier

CONTRIBUTING.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,42 @@ Request features on the [Issue Tracker].
3939

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

42-
- [Poetry]
43-
- [Nox]
44-
- [nox-poetry]
42+
- [Hatch]
4543

4644
Install the package with development requirements:
4745

4846
```console
49-
$ poetry install
47+
$ hatch env create
5048
```
5149

5250
You can now run an interactive Python session:
5351

5452
```console
55-
$ poetry run python
53+
$ hatch shell
5654
import human_readable
5755
```
5856

59-
[poetry]: https://python-poetry.org/
60-
[nox]: https://nox.thea.codes/
61-
[nox-poetry]: https://nox-poetry.readthedocs.io/
57+
[hatch]: https://hatch.pypa.io/
6258

6359
## How to test the project
6460

6561
Run the full test suite:
6662

6763
```console
68-
$ nox
64+
$ hatch run all
6965
```
7066

71-
List the available Nox sessions:
67+
List the available Hatch env scripts:
7268

7369
```console
74-
$ nox --list-sessions
70+
$ hatch env show
7571
```
7672

77-
You can also run a specific Nox session.
73+
You can run a specific Hatch env script.
7874
For example, invoke the unit test suite like this:
7975

8076
```console
81-
$ nox --session=tests
77+
$ hatch run tests:run
8278
```
8379

8480
Unit tests are located in the `tests` directory,

0 commit comments

Comments
 (0)