Skip to content

Commit 297976b

Browse files
authored
chore: migrate from Poetry to uv (#220)
1 parent 38ce3ae commit 297976b

File tree

13 files changed

+662
-1046
lines changed

13 files changed

+662
-1046
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,3 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8-
9-
# Maintain dependencies for poetry
10-
- package-ecosystem: "pip"
11-
directory: "/"
12-
schedule:
13-
interval: "daily"

.github/workflows/python-app.yml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,51 @@ on:
77
branches: [main]
88

99
jobs:
10-
test:
10+
lint:
11+
name: Lint
1112
runs-on: ubuntu-latest
1213
strategy:
1314
fail-fast: false
1415
matrix:
15-
python-version:
16-
- "3.12"
16+
python-version: ["3.12", "3.13"]
1717

1818
steps:
1919
- uses: actions/checkout@v4
2020

21-
- name: Install Poetry
22-
run: pipx install poetry
23-
24-
- name: Configure Poetry virtualenv
25-
run: poetry config virtualenvs.in-project true
26-
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v5
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v4
2923
with:
3024
python-version: ${{ matrix.python-version }}
31-
cache: poetry
32-
33-
- run: poetry env use ${{ matrix.python-version }}
34-
35-
- name: Install dependencies
36-
run: poetry install --no-interaction
25+
version: latest
3726

38-
- name: Check Poetry config and lockfile
39-
run: poetry run pre-commit run poetry-check --all-files
27+
- name: Check uv.lock
28+
run: uv run --frozen pre-commit run uv-lock-check --all-files
4029

4130
- name: Lint (ruff)
42-
run: poetry run ruff check . --config pyproject.toml --output-format=github --no-fix
31+
run: uv run --frozen ruff check . --config pyproject.toml --output-format=github --no-fix
4332

4433
- name: Formatting (ruff)
45-
run: poetry run pre-commit run ruff-format --all-files --show-diff-on-failure
34+
run: uv run --frozen pre-commit run ruff-format --all-files --show-diff-on-failure
4635

4736
- name: Typing (pyright)
48-
run: poetry run pre-commit run pyright --all-files
37+
run: uv run --frozen pre-commit run pyright --all-files
38+
39+
test:
40+
name: Test
41+
runs-on: ubuntu-latest
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
python-version: ["3.12", "3.13"]
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v4
52+
with:
53+
python-version: ${{ matrix.python-version }}
54+
version: latest
4955

5056
- name: Test
51-
run: poetry run pytest tests
57+
run: uv run --frozen pytest tests

.github/workflows/python-publish.yml

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,19 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414

15-
- name: Set up Python
16-
uses: actions/setup-python@v5
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v4
1717
with:
1818
python-version: "3.12"
19-
20-
- name: Get Python version
21-
id: python-version
22-
run: echo version="$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> "$GITHUB_OUTPUT"
23-
24-
- name: Run Poetry image
25-
uses: abatilo/[email protected]
26-
with:
27-
poetry-version: "1.1.12"
28-
29-
- name: Set Poetry virtualenv
30-
run: poetry config virtualenvs.in-project true
31-
32-
- name: Set up cache
33-
uses: actions/cache@v4
34-
id: cache
35-
with:
36-
path: .venv
37-
key: venv-${{ runner.os }}-${{ steps.python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
38-
39-
- name: Ensure cache is healthy
40-
if: steps.cache.outputs.cache-hit == 'true'
41-
shell: bash
42-
run: timeout 10s python -m poetry run pip --version || rm -rf .venv
43-
44-
- name: Install dependencies
45-
run: poetry install --no-interaction
46-
47-
# - name: Bump version
48-
# env:
49-
# VERSION: ${{ github.event.release.tag_name }}
50-
# run: poetry version $(echo $VERSION | sed -e 's/^v//')
19+
version: latest
5120

5221
- name: Build
53-
run: poetry build
22+
run: uv build
5423

5524
- name: Publish TestPyPI
25+
run: uv publish --trusted-publishing always -r testpypi
5626
env:
57-
POETRY_REPOSITORIES_TESTPYPI_URL: https://test.pypi.org/legacy/
58-
POETRY_HTTP_BASIC_TESTPYPI_USERNAME: __token__
59-
POETRY_HTTP_BASIC_TESTPYPI_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
60-
run: poetry publish -r testpypi
27+
UV_PUBLISH_URL: https://test.pypi.org/legacy/
6128

6229
- name: Publish PyPI
63-
env:
64-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
65-
run: poetry publish
30+
run: uv publish --trusted-publishing always

.pre-commit-config.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
repos:
33
- repo: local
44
hooks:
5-
- id: poetry-install
6-
name: poetry-install
7-
description: install Poetry dependencies from the lock file
8-
entry: poetry install
5+
- id: uv-sync
6+
name: uv-sync
7+
description: install uv dependencies from the lock file
8+
entry: uv sync
99
language: python
1010
pass_filenames: false
1111
stages: [post-checkout, post-merge]
1212
always_run: true
13-
- id: poetry-check
14-
name: poetry-check
15-
description: validate Poetry config and dependency lock file
16-
entry: poetry check
13+
- id: uv-lock-check
14+
name: uv-lock-check
15+
description: validate uv dependency lock file
16+
entry: uv lock --check
1717
language: python
1818
pass_filenames: false
19-
files: ^(.*/)?(pyproject\.toml|poetry\.lock)$
19+
files: ^(.*/)?(pyproject\.toml|uv\.lock)$
2020
- id: ruff-lint
2121
name: ruff-lint
22-
entry: poetry run ruff check
22+
entry: uv run ruff check
2323
args:
2424
[
2525
--force-exclude,
@@ -34,14 +34,14 @@ repos:
3434
require_serial: true # run once for all files
3535
- id: ruff-format
3636
name: ruff-format
37-
entry: poetry run ruff format
37+
entry: uv run ruff format
3838
args: [--force-exclude, --config, pyproject.toml]
3939
language: system
4040
types_or: [python]
4141
require_serial: true # run once for all files
4242
- id: pyright
4343
name: pyright
44-
entry: poetry run pyright
44+
entry: uv run pyright
4545
language: system
4646
types: [python]
4747
require_serial: true # run once for all files

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,10 @@ things.commit(todo)
4444

4545
See [main.py](./main.py).
4646

47-
1. Install dependencies
47+
Pass your Things Cloud credentials as environment examples to run the example
4848

4949
```sh
50-
poetry install
51-
```
52-
53-
2. Pass your Things Cloud credentials as environment examples to run the example
54-
55-
```sh
56-
[email protected] THINGS_PASSWORD=your-password python main.py
50+
[email protected] THINGS_PASSWORD=your-password uv run main.py
5751
```
5852

5953
### Progress

0 commit comments

Comments
 (0)