Skip to content

Commit d6e4191

Browse files
committed
Migrate from Poetry to uv
Switch dependency management and build tooling from Poetry to uv, matching the configuration pattern used in the circulation repo (PR ThePalaceProject/circulation#3221). - Rewrite pyproject.toml using PEP 621 [project] + hatchling build backend; move dev/ci deps to PEP 735 [dependency-groups]; git subdirectory deps move to [tool.uv.sources] (palace-util now resolves transitively via palace-opds). - Replace poetry.lock with uv.lock. - tox.ini uses the uv-venv-lock-runner (tox-uv). - GitHub workflows use astral-sh/setup-uv; lint workflow gets a pre-commit cache. - Dependabot switches from pip to uv ecosystem. - README documents uv-based setup.
1 parent 5df8a21 commit d6e4191

11 files changed

Lines changed: 1252 additions & 1694 deletions

File tree

.github/dependabot.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
version: 2
55
updates:
6-
- package-ecosystem: "pip"
6+
- package-ecosystem: "uv"
77
directory: "/"
88
schedule:
99
interval: "daily"
1010
versioning-strategy: increase-if-necessary
11+
cooldown:
12+
default-days: 4
1113

1214
- package-ecosystem: "github-actions"
1315
directory: "/"

.github/workflows/lint.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,23 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v6
1515

16-
- name: Set up Python
17-
uses: actions/setup-python@v6
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v8.0.0
1818
with:
19+
enable-cache: true
20+
cache-dependency-glob: uv.lock
1921
python-version: ${{ env.PYTHON_VERSION }}
20-
21-
- name: Install Poetry
22-
uses: ThePalaceProject/circulation/.github/actions/poetry@main
23-
with:
24-
version: "2.2.1"
25-
cache: false
22+
activate-environment: true
2623

2724
- name: Install Pre-commit
28-
run: |
29-
poetry install --only ci
30-
env:
31-
POETRY_VIRTUALENVS_CREATE: false
25+
run: uv sync --frozen --only-group ci
26+
27+
- name: Restore pre-commit cache
28+
uses: actions/cache@v5
29+
with:
30+
path: ~/.cache/pre-commit
31+
key: pre-commit-${{ runner.os }}-py${{ env.PYTHON_VERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}
32+
restore-keys: pre-commit-${{ runner.os }}-py${{ env.PYTHON_VERSION }}
3233

3334
- name: Lint
3435
run: pre-commit run --all-files --show-diff-on-failure

.github/workflows/mypy.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,16 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v6
1414

15-
- name: Set up Python 🐍
16-
uses: actions/setup-python@v6
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v8.0.0
1717
with:
18+
enable-cache: true
19+
cache-dependency-glob: uv.lock
1820
python-version: ${{ env.PYTHON_VERSION }}
19-
20-
- name: Install Poetry 🎸
21-
uses: ThePalaceProject/circulation/.github/actions/poetry@main
22-
with:
23-
version: "2.2.1"
24-
cache: true
25-
cache-name: without-ci
26-
27-
- name: Install OS Packages 🧰
28-
run: |
29-
sudo apt-get update
21+
activate-environment: true
3022

3123
- name: Install Python Packages 📦
32-
run: poetry install --without ci
24+
run: uv sync --frozen --no-group ci
3325

3426
- name: Run MyPy 🪄
35-
run: poetry run mypy
27+
run: mypy

.github/workflows/test.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,16 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v6
1414

15-
- name: Set up Python 🐍
16-
uses: actions/setup-python@v6
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v8.0.0
1717
with:
18+
enable-cache: true
19+
cache-dependency-glob: uv.lock
1820
python-version: ${{ env.PYTHON_VERSION }}
21+
activate-environment: true
1922

20-
- name: Install Poetry 🎸
21-
uses: ThePalaceProject/circulation/.github/actions/poetry@main
22-
with:
23-
version: "2.2.1"
24-
cache: true
25-
cache-name: without-ci
26-
27-
- name: Install OS Packages 🧰
28-
run: |
29-
sudo apt-get update
30-
31-
- name: Install Python Packages 📦
32-
run: poetry install --without ci
23+
- name: Install Tox 🧪
24+
run: uv sync --frozen --only-group ci
3325

34-
- name: Run Tests with Tox 🧪
35-
run: poetry run tox
26+
- name: Run Tests 🧪
27+
run: tox

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ __pycache__/
1414
env/
1515
env2/
1616
venv/
17+
.venv/
1718
build/
1819
develop-eggs/
1920
dist/

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repos:
1414
- id: check-executables-have-shebangs
1515
- id: check-merge-conflict
1616
- id: check-added-large-files
17+
exclude: ^uv\.lock$
1718
- id: mixed-line-ending
1819

1920
- repo: https://github.com/asottile/pyupgrade

README.md

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,21 @@ manifest conforming to the [Audiobook Profile](https://github.com/readium/webpub
4949

5050
## Working as a developer on this project
5151

52-
### pyenv
52+
### uv
5353

54-
[pyenv](https://github.com/pyenv/pyenv) lets you easily switch between multiple versions of Python. It can be
55-
[installed](https://github.com/pyenv/pyenv-installer) using the command `curl https://pyenv.run | bash`. You can then
56-
install the version of Python you want to work with.
54+
This project uses [uv](https://docs.astral.sh/uv/) for Python and dependency management.
55+
If you plan to work on this project, you will need `uv`.
5756

58-
It is recommended that [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) be used to allow `pyenv`
59-
to manage _virtual environments_ in a manner that can be used by the [poetry](#poetry) tool. The `pyenv-virtualenv`
60-
plugin can be installed by cloning the relevant repository into the `plugins` subdirectory of your `$PYENV_ROOT`:
57+
uv can be installed with `curl -LsSf https://astral.sh/uv/install.sh | sh`. See the
58+
[uv documentation](https://docs.astral.sh/uv/getting-started/installation/) for other
59+
installation options.
6160

62-
```sh
63-
mkdir -p $PYENV_ROOT/plugins
64-
cd $PYENV_ROOT/plugins
65-
git clone https://github.com/pyenv/pyenv-virtualenv
66-
```
67-
68-
After cloning the repository, `pyenv` now has a new `virtualenv` command:
61+
Once uv is installed, you can install the required Python version with:
6962

7063
```sh
71-
$ pyenv virtualenv
72-
pyenv-virtualenv: no virtualenv name given.
64+
uv python install 3.12
7365
```
7466

75-
### Poetry
76-
77-
This project uses [poetry](https://python-poetry.org/) for dependency management.
78-
If you plan to work on this project, you will need `poetry`.
79-
80-
Poetry can be installed using the command `curl -sSL https://install.python-poetry.org | python3 -`.
81-
82-
More information about installation options can be found in the
83-
[poetry documentation](https://python-poetry.org/docs/master/#installation).
84-
8567
## Installation
8668

8769
This package is not currently available oon PyPI, but it can be installed and run locally in a couple of
@@ -111,8 +93,7 @@ If installation is successful, `pipx` will list the apps that are installed with
11193

11294
- Clone the repository.
11395
- Change into the cloned directory.
114-
- Run `pyenv virtualenv <python-version> <virtualenv-name>` to create a Python virtual environment.
115-
- Run `pyenv local <virtualenv-name>` to use that virtual environment whenever in the cloned directory.
116-
- Run `poetry install` to install the project dependencies and the CLI tools into the virtual environment.
96+
- Run `uv sync --all-groups` to install the project dependencies and the CLI tools into a
97+
`.venv` virtual environment.
11798

118-
At this point, you should be able to run the CLI tools using `poetry run <cli-command-and-args>`.
99+
At this point, you should be able to run the CLI tools using `uv run <cli-command-and-args>`.

0 commit comments

Comments
 (0)