Skip to content

Commit da83ee4

Browse files
committed
Migrate from poetry to uv
1 parent 601d5e2 commit da83ee4

4 files changed

Lines changed: 81 additions & 68 deletions

File tree

.github/workflows/test-pr.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ jobs:
1414
- name: 'Check out code'
1515
uses: actions/checkout@v3
1616
- name: 'Install Python'
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: '3.10'
20+
- name: 'Install uv'
21+
uses: astral-sh/setup-uv@v5
2022
- name: 'Install cookiecutter'
2123
run: pip install cookiecutter
22-
- name: 'Install Poetry'
23-
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
2424
- name: 'Generate template'
2525
run: cookiecutter --no-input . project_name='Test Project'
2626
- name: 'Generate lock file'
27-
run: poetry -C ./test-project lock
27+
run: uv --project ./test-project lock
2828
- name: 'Cache generated project'
29-
uses: actions/cache@v3
29+
uses: actions/cache@v4
3030
with:
3131
path: ./test-project
3232
key: test-project-${{ github.run_id }}
@@ -37,16 +37,16 @@ jobs:
3737
runs-on: ubuntu-latest
3838
strategy:
3939
matrix:
40-
python-version: ['3.10', '3.11']
40+
python-version: ['3.10', '3.11', '3.12', '3.13']
4141
steps:
4242
- name: 'Install Python'
43-
uses: actions/setup-python@v4
43+
uses: actions/setup-python@v5
4444
with:
4545
python-version: ${{ matrix.python-version }}
46-
- name: 'Install Poetry'
47-
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
46+
- name: 'Install uv'
47+
uses: astral-sh/setup-uv@v5
4848
- name: 'Restore generated project'
49-
uses: actions/cache@v3
49+
uses: actions/cache@v4
5050
with:
5151
path: ./test-project
5252
key: test-project-${{ github.run_id }}
Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
POETRY := poetry
2-
POETRY_RUN := $(POETRY) run
1+
UV := uv
2+
UV_RUN := $(UV) run --
33

44

55
default: check test-unit
@@ -13,11 +13,7 @@ clean:
1313

1414
.PHONY: build
1515
build:
16-
$(POETRY) build
17-
18-
.PHONY: poetry-install
19-
poetry-install:
20-
$(POETRY) install
16+
$(uv) build
2117

2218

2319
# Tests
@@ -26,14 +22,17 @@ TEST_ARGS :=
2622

2723
test: test-all
2824

29-
test-all: poetry-install
30-
$(POETRY_RUN) pytest src/tests --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)
25+
.PHONY: test-all
26+
test-all:
27+
$(UV_RUN) pytest src/tests --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)
3128

32-
test-unit: poetry-install
33-
$(POETRY_RUN) pytest src/tests/unit --maxfail=1 --verbose $(TEST_ARGS)
29+
.PHONY: test-unit
30+
test-unit:
31+
$(UV_RUN) pytest src/tests/unit --maxfail=1 --verbose $(TEST_ARGS)
3432

35-
test-integration: poetry-install
36-
$(POETRY_RUN) pytest src/tests/integration --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)
33+
.PHONY: test-integration
34+
test-integration:
35+
$(UV_RUN) pytest src/tests/integration --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)
3736

3837

3938
# Coverage
@@ -59,34 +58,43 @@ cov-integration: test-integration
5958
format: autoflake isort black
6059
check: check-flake8 check-mypy check-autoflake check-isort check-black
6160

62-
check-flake8: poetry-install
63-
$(POETRY_RUN) flake8 src
61+
.PHONY: check-flake8
62+
check-flake8:
63+
$(UV_RUN) flake8 src
6464

65-
check-mypy: poetry-install
66-
$(POETRY_RUN) mypy src
65+
.PHONY: check-mypy
66+
check-mypy:
67+
$(UV_RUN) mypy src
6768

68-
autoflake: poetry-install
69-
$(POETRY_RUN) autoflake --quiet --in-place src
69+
.PHONY: autoflake
70+
autoflake:
71+
$(UV_RUN) autoflake --quiet --in-place src
7072

71-
check-autoflake: poetry-install
72-
$(POETRY_RUN) autoflake --quiet --check src
73+
.PHONY: check-autoflake
74+
check-autoflake:
75+
$(UV_RUN) autoflake --quiet --check src
7376

74-
isort: poetry-install
75-
$(POETRY_RUN) isort src
77+
.PHONY: isort
78+
isort:
79+
$(UV_RUN) isort src
7680

77-
check-isort: poetry-install
78-
$(POETRY_RUN) isort --check src
81+
.PHONY: check-isort
82+
check-isort:
83+
$(UV_RUN) isort --check src
7984

80-
black: poetry-install
81-
$(POETRY_RUN) black src
85+
.PHONY: black
86+
black:
87+
$(UV_RUN) black src
8288

83-
check-black: poetry-install
84-
$(POETRY_RUN) black --check src
89+
.PHONY: check-black
90+
check-black:
91+
$(UV_RUN) black --check src
8592

8693

8794
# Optional tools
8895

8996
SRC_FILES := $(shell find src -type f -name '*.py')
9097

91-
pyupgrade: poetry-install
92-
$(POETRY_RUN) pyupgrade --py310-plus $(SRC_FILES)
98+
.PHONY: pyupgrade
99+
pyupgrade:
100+
$(UV_RUN) pyupgrade --py310-plus $(SRC_FILES)

{{cookiecutter.project_slug}}/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## Installation
55

6-
Prerequsites: `python >= 3.10`, `pip >= 20.0.2`, `poetry >= 1.3.2`.
6+
Prerequsites: `python >= 3.10`, [`uv`](https://docs.astral.sh/uv/).
77

88
```bash
99
make build
@@ -19,5 +19,4 @@ Use `make` to run common tasks (see the [Makefile](Makefile) for a complete list
1919
* `make check`: Check code style
2020
* `make format`: Format code
2121
* `make test-unit`: Run unit tests
22-
23-
For interactive use, spawn a shell with `poetry shell` (after `poetry install`), then run an interpreter.
22+
* `make test-integration`: Run integration tests

{{cookiecutter.project_slug}}/pyproject.toml

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
[build-system]
2-
requires = ["poetry-core"]
3-
build-backend = "poetry.core.masonry.api"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

5-
[tool.poetry]
5+
[project]
66
name = "{{ cookiecutter.project_slug }}"
77
version = "{{ cookiecutter.version }}"
88
description = "{{ cookiecutter.description }}"
9-
authors = [
10-
"{{ cookiecutter.author_name }} <{{ cookiecutter.author_email }}>",
9+
readme = "README.md"
10+
requires-python = "~=3.10"
11+
dependencies = []
12+
13+
[[project.authors]]
14+
name = "{{ cookiecutter.author_name }}"
15+
email = "{{ cookiecutter.author_email }}"
16+
17+
[dependency-groups]
18+
dev = [
19+
"autoflake",
20+
"black",
21+
"flake8",
22+
"flake8-bugbear",
23+
"flake8-comprehensions",
24+
"flake8-quotes",
25+
"flake8-type-checking",
26+
"isort",
27+
"mypy",
28+
"pep8-naming",
29+
"pytest",
30+
"pytest-cov",
31+
"pytest-mock",
32+
"pytest-xdist",
33+
"pyupgrade",
1134
]
1235

13-
[tool.poetry.dependencies]
14-
python = "^3.10"
15-
16-
[tool.poetry.group.dev.dependencies]
17-
autoflake = "*"
18-
black = "*"
19-
flake8 = "*"
20-
flake8-bugbear = "*"
21-
flake8-comprehensions = "*"
22-
flake8-quotes = "*"
23-
flake8-type-checking = "*"
24-
isort = "*"
25-
mypy = "*"
26-
pep8-naming = "*"
27-
pytest = "*"
28-
pytest-cov = "*"
29-
pytest-mock = "*"
30-
pytest-xdist = "*"
31-
pyupgrade = "*"
36+
[tool.hatch.metadata]
37+
allow-direct-references = true
3238

3339
[tool.isort]
3440
profile = "black"

0 commit comments

Comments
 (0)