Skip to content

Commit b80bcc4

Browse files
JWCookalessio-locatelli
authored andcommitted
Switch from poetry to uv
1 parent 4879cf4 commit b80bcc4

File tree

10 files changed

+2613
-3316
lines changed

10 files changed

+2613
-3316
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches: [main]
99
workflow_dispatch:
1010
env:
11-
LATEST_PY_VERSION: '3.12'
11+
LATEST_PY_VERSION: '3.13'
1212
COVERAGE_ARGS: '--cov --cov-report=term --cov-report=xml'
1313
XDIST_ARGS: '--numprocesses=auto --dist=loadfile'
1414

@@ -24,53 +24,42 @@ jobs:
2424
- '3.11'
2525
- '3.10'
2626
- '3.9'
27+
- '3.14-rc2'
2728
services:
2829
nginx:
2930
image: kennethreitz/httpbin
3031
ports:
3132
- 8080:80
3233

3334
steps:
35+
# Install dependencies, with caching
3436
- uses: actions/checkout@v5
35-
- uses: actions/setup-python@v6
36-
with:
37-
python-version: ${{ matrix.python-version }}
38-
- uses: snok/install-poetry@v1.4
37+
- uses: astral-sh/setup-uv@v6
3938
with:
40-
version: 1.8.5
41-
virtualenvs-in-project: true
39+
enable-cache: true
40+
cache-dependency-glob: uv.lock
41+
- name: Install dependencies
42+
run: |
43+
uv python install ${{ matrix.python-version }}
44+
uv sync --all-extras
4245
4346
# Start integration test databases
4447
- uses: supercharge/mongodb-github-action@1.12.0
4548
with:
46-
mongodb-version: 4.4
49+
mongodb-version: '5.0'
4750
- uses: supercharge/redis-github-action@1.8.0
4851
with:
4952
redis-version: '6'
5053
- uses: rrainn/dynamodb-action@v4.0.0
51-
52-
# Cache packages per python version, and reuse until lockfile changes
53-
- name: Cache python packages
54-
id: cache
55-
uses: actions/cache@v4
56-
with:
57-
path: .venv
58-
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
59-
- name: Install dependencies
60-
if: steps.cache.outputs.cache-hit != 'true'
61-
run: poetry install -v -E all
62-
6354
- name: Run custom test server
6455
run: |
65-
source $VENV
66-
cd test && gunicorn -D -c server/gunicorn-cfg.py server:app
56+
cd test && uv run gunicorn -D -c server/gunicorn-cfg.py server:app
6757
6858
# Run tests with coverage report
6959
- name: Run tests
7060
run: |
71-
source $VENV
72-
pytest -rs test/unit ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}
73-
pytest -rs test/integration --cov-append ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}
61+
uv run pytest -rs test/unit ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}
62+
uv run pytest -rs test/integration --cov-append ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}
7463
7564
# Latest python version: send coverage report to codecov
7665
- name: 'Upload coverage report to Codecov'

.github/workflows/deploy.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,29 @@ on:
1313
description: 'Version number for pre-releases; defaults to build number'
1414
required: false
1515
default: ''
16-
env:
17-
LATEST_PY_VERSION: '3.12'
1816

1917
jobs:
2018
# Deploy stable builds on tags only, and pre-release builds from manual trigger ("workflow_dispatch")
2119
release:
2220
runs-on: ubuntu-latest
21+
permissions:
22+
id-token: write
2323
steps:
2424
- uses: actions/checkout@v5
25-
- uses: actions/setup-python@v6
26-
with:
27-
python-version: ${{ env.LATEST_PY_VERSION }}
28-
- uses: snok/install-poetry@v1.4
29-
with:
30-
virtualenvs-in-project: true
25+
- uses: astral-sh/setup-uv@v6
3126

3227
- name: Set pre-release version
3328
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
3429
env:
3530
pre-release-suffix: ${{ github.event.inputs.pre-release-suffix || 'dev' }}
3631
pre-release-version: ${{ github.event.inputs.pre-release-version || github.run_number }}
3732
run: |
38-
poetry version $(poetry version -s).${{ env.pre-release-suffix }}${{ env.pre-release-version }}
39-
poetry version
33+
PKG_VERSION=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)
34+
DEV_VERSION=$PKG_VERSION.${{ env.pre-release-suffix }}${{ env.pre-release-version }}
35+
echo "Setting pre-release version to $DEV_VERSION"
36+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $DEV_VERSION
4037
41-
- name: Build and publish to pypi
42-
run: |
43-
poetry build
44-
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}
38+
- name: Build package distributions
39+
run: uv build
40+
- name: Publish package distributions to PyPI
41+
uses: pypa/gh-action-pypi-publish@release/v1

.readthedocs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ build:
1010
tools:
1111
python: '3.12'
1212
jobs:
13-
# Use poetry to export optional + documentation dependencies
13+
# Use uv to export optional + documentation dependencies
1414
post_create_environment:
15-
- python -m pip install poetry poetry-plugin-export
16-
- poetry export -o docs/requirements.txt --all-extras --with=docs
15+
- pip install uv
16+
- uv export -q --no-dev --group docs --no-emit-project -o docs/requirements.txt
1717
python:
1818
install:
19+
- method: pip
20+
path: .
1921
- requirements: docs/requirements.txt

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
## Dev Installation
44

5-
To set up for local development (requires [poetry](https://python-poetry.org/docs/#installation)):
5+
To set up for local development (requires [uv](https://docs.astral.sh/uv/getting-started/installation/)):
66

77
```sh
88
$ git clone https://github.com/requests-cache/aiohttp-client-cache
99
$ cd aiohttp-client-cache
10-
$ poetry install -E all
10+
$ uv sync --all-extras
1111
```
1212

1313
## Pre-commit hooks
@@ -48,9 +48,9 @@ Tests are divided into unit and integration tests:
4848

4949
### Running Tests
5050

51-
- Run `pytest` to run all tests
52-
- Run `pytest test/unit` to run only unit tests
53-
- Run `pytest test/integration` to run only integration tests
51+
- Run `uv run pytest` to run all tests
52+
- Run `uv run pytest test/unit` to run only unit tests
53+
- Run `uv run pytest test/integration` to run only integration tests
5454

5555
For CI jobs (including PRs), these tests will be run for each supported python version.
5656
You can use [nox](https://nox.thea.codes) to do this locally, if needed:
@@ -83,11 +83,11 @@ Then, run:
8383

8484
```sh
8585
docker-compose up -d
86-
pytest test/integration
86+
uv run pytest test/integration
8787
```
8888

8989
To test DragonflyDB you need to stop a Redis container (if running) and run `docker compose -f dragonflydb.yaml up`.
90-
No other changes are required, you can run related tests with e.g. `pytest test -k redis`.
90+
No other changes are required, you can run related tests with e.g. `uv run pytest test -k redis`.
9191

9292
## Documentation
9393

@@ -96,7 +96,7 @@ No other changes are required, you can run related tests with e.g. `pytest test
9696
First, install documentation dependencies:
9797

9898
```sh
99-
$ poetry install -E all --with docs
99+
$ uv sync --all-extras
100100
```
101101

102102
To build the docs locally:

HISTORY.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# History
22

3+
## Unreleased
4+
5+
- Packaging and project config are now handled with [uv](https://docs.astral.sh/uv/). For users, installation still works the same. For developers, see [Contributing Guide](https://aiohttp-client-cache.readthedocs.io/en/stable/contributing.html) for details.
6+
37
## 0.14.1 (2025-10-01)
48

59
- Update type annotation for `CachedSession.__aenter__` with `Self` type
@@ -195,8 +199,6 @@
195199
- `Expires`
196200
- Add support for HTTP timestamps (RFC 5322) in `expire_after` parameters
197201
- Add a `use_temp` option to `SQLiteBackend` to use a tempfile
198-
- Packaging is now handled with Poetry. For users, installation still works the same. For developers,
199-
see [Contributing Guide](https://aiohttp-client-cache.readthedocs.io/en/stable/contributing.html) for details
200202
- Published package on [conda-forge](https://anaconda.org/conda-forge/aiohttp-client-cache)
201203

202204
## 0.3.0 (2021-04-09)

noxfile.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Notes:
2-
* 'test' command: nox will use poetry.lock to determine dependency versions
2+
* 'test' command: nox will use uv.lock to determine dependency versions
33
* 'lint' command: tools and environments are managed by pre-commit
44
* All other commands: the current environment will be used instead of creating new ones
55
"""
@@ -9,7 +9,6 @@
99
from shutil import rmtree
1010

1111
import nox
12-
from nox_poetry import session
1312

1413
nox.options.reuse_existing_virtualenvs = True
1514
nox.options.sessions = ['lint', 'cov']
@@ -29,25 +28,35 @@
2928
XDIST_ARGS = '--numprocesses=auto --dist=loadfile' # Run tests in parallel, grouped by test module
3029

3130

32-
@session(python=['3.9', '3.10', '3.11', '3.12'])
31+
def install_deps(session):
32+
"""Install project and test dependencies into a test-specific virtualenv using uv"""
33+
session.env['UV_PROJECT_ENVIRONMENT'] = session.virtualenv.location
34+
session.run_install(
35+
'uv',
36+
'sync',
37+
'--frozen',
38+
'--all-extras',
39+
)
40+
41+
42+
@nox.session(python=['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'])
3343
def test(session):
3444
"""Run tests for a specific python version"""
3545
test_paths = session.posargs or [UNIT_TESTS]
36-
session.install('.', 'pytest', 'pytest-aiohttp', 'pytest-asyncio', 'pytest-xdist')
37-
46+
install_deps(session)
3847
cmd = f'pytest -rs {XDIST_ARGS}'
3948
session.run(*cmd.split(' '), *test_paths)
4049

4150

42-
@session(python=False)
51+
@nox.session(python=False)
4352
def clean(session):
4453
"""Clean up temporary build + documentation files"""
4554
for dir in CLEAN_DIRS:
4655
print(f'Removing {dir}')
4756
rmtree(dir, ignore_errors=True) # type: ignore[arg-type]
4857

4958

50-
@session(python=False, name='cov')
59+
@nox.session(python=False, name='cov')
5160
def coverage(session):
5261
"""Run tests and generate coverage report"""
5362
cmd_1 = f'pytest {UNIT_TESTS} -rs {XDIST_ARGS} {COVERAGE_ARGS}'
@@ -56,22 +65,22 @@ def coverage(session):
5665
session.run(*cmd_2.split(' '))
5766

5867

59-
@session(python=False)
68+
@nox.session(python=False)
6069
def docs(session):
6170
"""Build Sphinx documentation"""
6271
cmd = 'sphinx-build docs docs/_build/html -j auto'
6372
session.run(*cmd.split(' '))
6473

6574

66-
@session(python=False)
75+
@nox.session(python=False)
6776
def livedocs(session):
6877
"""Auto-build docs with live reload in browser.
6978
Add `--open` to also open the browser after starting.
7079
"""
7180
args = ['-a']
7281
args += [f'--watch {pattern}' for pattern in LIVE_DOCS_WATCH]
7382
args += [f'--ignore {pattern}' for pattern in LIVE_DOCS_IGNORE]
74-
args += [f'--port {LIVE_DOCS_PORT}', '-j auto']
83+
args += [f'--port {LIVE_DOCS_PORT}', '--host 0.0.0.0', '-j auto']
7584
if session.posargs == ['open']:
7685
args.append('--open-browser')
7786

@@ -80,8 +89,7 @@ def livedocs(session):
8089
session.run(*cmd.split(' '))
8190

8291

83-
@session(python=False)
92+
@nox.session(python=False)
8493
def lint(session):
8594
"""Run linters and code formatters via pre-commit"""
86-
cmd = 'pre-commit run --all-files'
87-
session.run(*cmd.split(' '))
95+
session.run('pre-commit', 'run', '--all-files')

0 commit comments

Comments
 (0)