Skip to content

Commit e9df989

Browse files
authored
Migrate build tool to uv (#136)
1 parent 0799a51 commit e9df989

File tree

7 files changed

+1766
-2074
lines changed

7 files changed

+1766
-2074
lines changed

.github/workflows/release.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,19 @@ jobs:
5858
with:
5959
python-version: ${{ matrix.python-versions }}
6060

61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v3
63+
6164
- name: Install dependencies
65+
if: ${{ !matrix.tox-full-run }}
6266
run: |
63-
python -m pip install --upgrade pip
64-
pip install poetry
65-
poetry install
67+
uv venv .venv
68+
uv pip install '.'
6669
6770
- name: Build documentation
6871
run: |
69-
poetry install -E doc
70-
poetry run mkdocs build
72+
uv pip install -e '.[doc]
73+
uv run mkdocs build
7174
7275
- name: Publish documentation
7376
uses: peaceiris/actions-gh-pages@v3
@@ -77,11 +80,11 @@ jobs:
7780

7881
- name: Build wheels and source tarball
7982
run: >-
80-
poetry build
83+
uv build
8184
8285
- name: show temporary files
8386
run: >-
8487
ls -l
8588
8689
- name: Publish to PyPi
87-
run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
90+
run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yml

+8-28
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,22 @@ jobs:
4545
- uses: actions/setup-python@v5
4646
with:
4747
python-version: ${{ matrix.python-version }}
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v3
4850

4951
- name: Install dependencies
50-
if: ${{ !matrix.tox-full-run }}
5152
run: |
52-
python -m pip install --upgrade pip
53-
pip install poetry tox tox-gh-actions
54-
poetry install --with test
53+
uv tool install --with tox-gh-actions --with tox-uv tox
5554
5655
- name: Test with tox
5756
if: ${{ !matrix.tox-full-run }}
5857
run:
59-
poetry run tox -e test
60-
61-
- name: Install dependencies
62-
if: ${{ matrix.tox-full-run }}
63-
run: |
64-
python -m pip install --upgrade pip
65-
pip install poetry tox tox-gh-actions
66-
poetry install --with test,dev,doc
58+
tox -e test
6759

6860
- name: Test with tox
6961
if: ${{ matrix.tox-full-run }}
7062
run:
71-
poetry run tox
63+
tox
7264

7365
- name: list files
7466
if: ${{ always() }}
@@ -88,30 +80,18 @@ jobs:
8880
files: coverage.xml
8981

9082
publish_dev_build:
91-
# if test failed, we should not publish
9283
needs: test
9384
runs-on: ubuntu-latest
9485
steps:
9586
- uses: actions/checkout@v4
9687
- uses: actions/setup-python@v5
9788
with:
9889
python-version: 3.9
99-
100-
- name: Install dependencies
101-
run: |
102-
python -m pip install --upgrade pip
103-
pip install poetry
104-
poetry install
105-
106-
- name: list files
107-
run: ls -l .
108-
90+
- name: Install uv
91+
uses: astral-sh/setup-uv@v3
10992
- name: Build wheels and source tarball
11093
run: |
111-
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
112-
poetry version --short
113-
poetry build
114-
94+
uv build
11595
- name: publish to Test PyPI
11696
uses: pypa/gh-action-pypi-publish@release/v1
11797
with:

poetry.lock

-1,969
This file was deleted.

pyproject.toml

+40-53
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
[tool]
2-
[tool.poetry]
1+
[project]
32
name = "dike"
43
version = "1.0.0"
54
homepage = "https://github.com/chr1st1ank/dike"
65
description = "Python asyncio tools for web service resilience."
7-
authors = ["Christian Krudewig <[email protected]>"]
6+
authors = [{ name = "Christian Krudewig", email = "[email protected]" }]
87
readme = "README.md"
98
license = "Apache-2.0"
109
classifiers = [
@@ -28,61 +27,49 @@ packages = [
2827
{ include = "dike" },
2928
{ include = "tests", format = "sdist" },
3029
]
30+
requires-python = ">=3.7.1,<4.0"
31+
dependencies = []
3132

32-
[tool.poetry.dependencies]
33-
python = ">=3.7.1,<4.0"
34-
35-
[tool.poetry.extras]
33+
[project.optional-dependencies]
3634
test = [
3735
"pytest",
3836
"phmdoctest",
3937
"pytest-cov",
40-
"yamllint"
38+
"yamllint",
39+
"xdoctest~=1.1"
40+
]
41+
dev = [
42+
'docutils; python_version == "3.9"',
43+
'bump2version ~= 1.0',
44+
'fastapi ~= 0.88',
45+
'httpcore ~= 0.16',
46+
'httpx ~= 0.23',
47+
'invoke ~= 2.0.0',
48+
'mkapi',
49+
'mkdocs ~= 1.4',
50+
'mkdocs-autorefs',
51+
'mkdocs-include-markdown-plugin',
52+
'numpy ~= 1.21',
53+
'phmdoctest ~= 1.2',
54+
'pre-commit ~= 2.20',
55+
'pytest ~= 7.1',
56+
'pytest-cov',
57+
'pytest-parametrized ~= 1.4',
58+
'safety ~= 2.3',
59+
'toml',
60+
'tox',
61+
'twine',
62+
'uvicorn ~= 0.20',
63+
'yamllint'
64+
]
65+
doc = [
66+
'pymdown-extensions ~= 9.7',
67+
'mkdocs ~= 1.4',
68+
'mkdocs-include-markdown-plugin ~= 4.0; python_version == "3.9"',
69+
'mkapi ~= 1.0',
70+
'mkdocs-autorefs ~= 0.4',
4171
]
42-
43-
[tool.poetry.group.dev]
44-
optional = true
45-
46-
[tool.poetry.group.dev.dependencies]
47-
docutils = { version = "0.21", python = "3.9" } # Necessary to manually add because of https://github.com/pypa/twine/issues/1082
48-
bump2version = "^1.0"
49-
fastapi = {version = "^0.88"}
50-
httpcore = "^0.16"
51-
httpx = "^0.23"
52-
invoke = "^2.0.0"
53-
mkapi = { version = "*" }
54-
mkdocs = { version = "^1.4" }
55-
mkdocs-autorefs = { version = "*" }
56-
mkdocs-include-markdown-plugin = { version = "*" }
57-
numpy = "~1.21"
58-
phmdoctest = "^1.2"
59-
pip = { version = "*" }
60-
pre-commit = { version = "^2.20" }
61-
pytest = "^7.1"
62-
pytest-cov = { version = "*" }
63-
pytest-parametrized = "^1.4"
64-
safety = "^2.3"
65-
toml = { version = "*" }
66-
tox = { version = "*" }
67-
twine = { version = "*" }
68-
uvicorn = "^0.20"
69-
virtualenv = { version = "^20.16" }
70-
yamllint = "*"
71-
72-
[tool.poetry.group.doc]
73-
optional = true
74-
75-
[tool.poetry.group.doc.dependencies]
76-
pymdown-extensions = "^9.7"
77-
mkdocs = "^1.4"
78-
mkdocs-include-markdown-plugin = { version = "^4.0", python = "3.9" }
79-
mkapi = "^1.0"
80-
mkdocs-autorefs = "^0.4"
81-
82-
83-
[tool.poetry.group.test.dependencies]
84-
xdoctest = "^1.1.0"
8572

8673
[build-system]
87-
requires = ["poetry-core>=1.0.0"]
88-
build-backend = "poetry.core.masonry.api"
74+
requires = ["hatchling"]
75+
build-backend = "hatchling.build"

tasks.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,29 @@ def clean(c):
7676
"""Run all clean sub-tasks."""
7777

7878

79-
@task()
80-
def install_hooks(c):
81-
# type: (Context) -> None
82-
"""Install pre-commit hooks."""
83-
_run(c, "poetry run pre-commit install")
84-
85-
8679
@task()
8780
def hooks(c):
8881
# type: (Context) -> None
8982
"""Run pre-commit hooks."""
90-
_run(c, "poetry run pre-commit run --all-files")
83+
_run(c, "pre-commit run --all-files")
9184

9285

9386
@task(name="format", help={"check": "Checks if source is formatted without applying changes"})
9487
def format_(c, check=False):
9588
# type: (Context, bool) -> None
9689
"""Format code."""
9790
isort_options = ["--check-only", "--diff"] if check else []
98-
_run(c, f"poetry run isort {' '.join(isort_options)} {PYTHON_TARGETS_STR}")
91+
_run(c, f"uv run isort {' '.join(isort_options)} {PYTHON_TARGETS_STR}")
9992
black_options = ["--diff", "--check"] if check else ["--quiet"]
100-
_run(c, f"poetry run black {' '.join(black_options)} {PYTHON_TARGETS_STR}")
93+
_run(c, f"uv run black {' '.join(black_options)} {PYTHON_TARGETS_STR}")
10194

10295

10396
@task()
10497
def tests(c):
10598
# type: (Context) -> None
10699
"""Run tests."""
107100
pytest_options = ["--xdoctest", "--cov", "--cov-report=", "--cov-fail-under=0"]
108-
_run(c, f"poetry run pytest {' '.join(pytest_options)} {TEST_DIR} {SOURCE_DIR}")
101+
_run(c, f"uv run pytest {' '.join(pytest_options)} {TEST_DIR} {SOURCE_DIR}")
109102

110103

111104
@task(
@@ -118,8 +111,8 @@ def coverage(c, fmt="report", open_browser=False):
118111
# type: (Context, str, bool) -> None
119112
"""Create coverage report."""
120113
if any(Path().glob(".coverage.*")):
121-
_run(c, "poetry run coverage combine")
122-
_run(c, f"poetry run coverage {fmt} -i")
114+
_run(c, "uv run coverage combine")
115+
_run(c, f"uv run coverage {fmt} -i")
123116
if fmt == "html" and open_browser:
124117
webbrowser.open(COVERAGE_REPORT.as_uri())
125118

@@ -128,7 +121,7 @@ def coverage(c, fmt="report", open_browser=False):
128121
def docs(c):
129122
# type: (Context) -> None
130123
"""Build documentation."""
131-
_run(c, "poetry run mkdocs build")
124+
_run(c, "uv run mkdocs build")
132125

133126

134127
@task(pre=[clean, hooks, docs, tests, coverage])
@@ -154,4 +147,4 @@ def version(c, part, dry_run=False, allow_dirty=False):
154147
bump_options.append("--dry-run")
155148
if allow_dirty:
156149
bump_options.append("--allow-dirty")
157-
_run(c, f"poetry run bump2version {' '.join(bump_options)} {part}")
150+
_run(c, f"uv run bump2version {' '.join(bump_options)} {part}")

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ python =
1313

1414
[testenv:build]
1515
allowlist_externals =
16-
poetry
16+
uv
1717
mkdocs
1818
twine
1919
extras =
2020
test
2121
doc
2222
dev
2323
commands =
24-
poetry build
24+
uv build
2525
mkdocs build
2626
twine check dist/*
2727

0 commit comments

Comments
 (0)