Skip to content

Commit 548621c

Browse files
YazdanRaLee-Wbenediktziegler
authored
build(uv): switch from poetry to uv for project management (#1749)
Co-authored-by: Wei Lee <[email protected]> Co-authored-by: Benedikt Ziegler <[email protected]>
1 parent 6990d51 commit 548621c

File tree

11 files changed

+1777
-2216
lines changed

11 files changed

+1777
-2216
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Please fill in the following content to let us know better about this change.
1414
### Code Changes
1515

1616
- [ ] Add test cases to all the changes you introduce
17-
- [ ] Run `poetry all` locally to ensure this change passes linter check and tests
17+
- [ ] Run `uv run poe all` locally to ensure this change passes linter check and tests
1818
- [ ] Manually test the changes:
1919
- [ ] Verify the feature/bug fix works as expected in real-world scenarios
2020
- [ ] Test edge cases and error conditions
@@ -24,10 +24,10 @@ Please fill in the following content to let us know better about this change.
2424

2525
### Documentation Changes
2626

27-
- [ ] Run `poetry doc` locally to ensure the documentation pages renders correctly
27+
- [ ] Run `uv run poe doc` locally to ensure the documentation pages renders correctly
2828
- [ ] Check and fix any broken links (internal or external) in the documentation
2929

30-
> When running `poetry doc`, any broken internal documentation links will be reported in the console output like this:
30+
> When running `uv run poe doc`, any broken internal documentation links will be reported in the console output like this:
3131
>
3232
> ```text
3333
> INFO - Doc file 'config.md' contains a link 'commands/bump.md#-post_bump_hooks', but the doc 'commands/bump.md' does not contain an anchor '#-post_bump_hooks'.

.github/workflows/docspublish.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ jobs:
1515
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
1616
fetch-depth: 0
1717
- name: Set up Python
18-
uses: actions/setup-python@v6
18+
uses: astral-sh/setup-uv@v7
1919
with:
2020
python-version: "3.x"
2121
- name: Install dependencies
2222
run: |
23-
python -m pip install -U pip poetry poethepoet
24-
poetry --version
25-
poetry install --only main,script
23+
uv --version
24+
uv sync --locked --group script
2625
- name: Update CLI screenshots
2726
run: |
28-
poetry doc:screenshots
27+
uv run poe doc:screenshots
2928
- name: Commit and push updated CLI screenshots
3029
run: |
3130
git config --global user.name "github-actions[bot]"
@@ -51,14 +50,13 @@ jobs:
5150
run: |
5251
git pull origin master
5352
- name: Set up Python
54-
uses: actions/setup-python@v6
53+
uses: astral-sh/setup-uv@v7
5554
with:
5655
python-version: "3.x"
5756
- name: Install dependencies
5857
run: |
59-
python -m pip install -U pip poetry poethepoet
60-
poetry --version
61-
poetry install --no-root --only documentation
58+
uv --version
59+
uv sync --locked --only-group documentation
6260
- name: Generate Sponsors 💖
6361
uses: JamesIves/github-sponsors-readme-action@v1
6462
with:
@@ -69,7 +67,7 @@ jobs:
6967
env:
7068
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7169
run: |
72-
poetry doc:build
70+
uv run poe doc:build
7371
- name: Deploy 🚀
7472
uses: JamesIves/github-pages-deploy-action@v4
7573
with:

.github/workflows/homebrewpublish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
- name: Checkout
1515
uses: actions/checkout@v6
1616
- name: Set up Python
17-
uses: actions/setup-python@v6
17+
uses: astral-sh/setup-uv@v7
1818
with:
1919
python-version: "3.x"
2020
- name: Install dependencies
21-
run: |
22-
python -m pip install -U commitizen
21+
run: uv pip install -U commitizen
2322
- name: Set Project version env variable
2423
run: |
2524
echo "project_version=$(cz version --project)" >> $GITHUB_ENV

.github/workflows/pythonpackage.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,18 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v6
22+
uses: astral-sh/setup-uv@v7
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install dependencies
2626
run: |
27-
python -m pip install -U pip poetry poethepoet
28-
poetry --version
29-
poetry install --only main,linters,test
27+
uv --version
28+
uv sync --locked --dev --group test --group linters
3029
- name: Run tests and linters
3130
run: |
3231
git config --global user.email "[email protected]"
3332
git config --global user.name "GitHub Action"
34-
poetry ci
33+
uv run poe ci
3534
shell: bash
3635
- name: Upload coverage to Codecov
3736
uses: codecov/codecov-action@v5

.github/workflows/pythonpublish.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ jobs:
1414
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
1515
fetch-depth: 0
1616
- name: Set up Python
17-
uses: actions/setup-python@v6
17+
uses: astral-sh/setup-uv@v7
1818
with:
1919
python-version: "3.x"
20-
- name: Install dependencies
21-
run: |
22-
python -m pip install -U pip poetry
23-
poetry --version
20+
- name: Build
21+
run: uv build
2422
- name: Publish
25-
env:
26-
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
27-
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28-
run: poetry publish --build
23+
run: uv publish

.pre-commit-config.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ repos:
2929
args: [ '--unsafe' ] # for mkdocs.yml
3030
- id: detect-private-key
3131

32+
- repo: https://github.com/astral-sh/uv-pre-commit
33+
rev: 0.9.18
34+
hooks:
35+
- id: uv-lock
36+
- id: uv-sync
37+
args: [ --locked, --all-groups ]
38+
stages: [ pre-commit, post-checkout, post-merge, post-rewrite ]
39+
3240
- repo: https://github.com/asottile/blacken-docs
3341
rev: 1.19.1
3442
hooks:
@@ -63,15 +71,15 @@ repos:
6371
- repo: local
6472
hooks:
6573
- id: format
66-
name: Format Python code via Poetry
74+
name: Format Python code
6775
language: system
6876
pass_filenames: false
69-
entry: poetry format
77+
entry: uv run poe format
7078
types: [ python ]
7179

7280
- id: linter and test
73-
name: Linters via Poetry
81+
name: Linters
7482
language: system
7583
pass_filenames: false
76-
entry: poetry lint
84+
entry: uv run poe lint
7785
types: [ python ]

docs/contributing.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you're a first-time contributor, please check out issues labeled [good first
1616

1717
1. **Python Environment**
1818
- Python `>=3.10`
19-
- [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) `>=2.2.0`
19+
- [uv](https://docs.astral.sh/uv/getting-started/installation/) `>=0.9.0`
2020
2. **Version Control & Security**
2121
- Git
2222
- Commitizen
@@ -38,13 +38,13 @@ If you're a first-time contributor, please check out issues labeled [good first
3838
```bash
3939
git remote add upstream https://github.com/commitizen-tools/commitizen.git
4040
```
41-
4. Set up the development environment (nix users go to [nix section](#nix)):
41+
4. Set up the development environment:
4242
```bash
43-
poetry install
43+
uv sync --dev
4444
```
4545
5. Set up pre-commit hooks:
4646
```bash
47-
poetry setup-pre-commit
47+
uv run poe setup-pre-commit
4848
```
4949

5050
## Development Workflow
@@ -61,15 +61,15 @@ If you're a first-time contributor, please check out issues labeled [good first
6161
- Update documentation if needed
6262
- Follow the existing code style
6363
3. **Testing**
64-
- Run the full test suite: `poetry all`
64+
- Run the full test suite: `uv run poe all`
6565
- Ensure test coverage doesn't drop (we use [CodeCov](https://app.codecov.io/gh/commitizen-tools/commitizen))
66-
- For documentation changes, run `poetry doc` to check for warnings/errors
66+
- For documentation changes, run `uv run poe doc` to check for warnings/errors
6767
4. **Committing Changes**
6868
- Use Commitizen to make commits (we follow [conventional commits](https://www.conventionalcommits.org/))
6969
- Example: `cz commit`
7070
5. **Documentation**
7171
- Update `docs/README.md` if needed
72-
- For CLI help screenshots: `poetry doc:screenshots`
72+
- For CLI help screenshots: `uv run poe doc:screenshots`
7373
- Prefer [Google style documentation](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings), which works well with editors like VSCode and PyCharm
7474
- **DO NOT** update `CHANGELOG.md` (automatically generated)
7575
- **DO NOT** update version numbers (automatically handled)
@@ -154,16 +154,3 @@ flowchart TD
154154
--modification-received-->
155155
review
156156
```
157-
158-
## Nix
159-
160-
If you have installed poetry globally, the project won't work because it requires `poethepoet` for command management.
161-
162-
You'll have to install poetry locally.
163-
164-
```sh
165-
python -m venv .venv
166-
. .venv/bin/activate
167-
pip install -U pip && pip install poetry
168-
poetry install
169-
```

docs/contributing_tldr.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Feel free to send a PR to update this file if you find anything useful. 🙇
33
## Environment
44

55
- Python `>=3.10`
6-
- [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) `>=2.2.0`
6+
- [uv](https://docs.astral.sh/uv/getting-started/installation/) `>=0.9.0`
77

88
## Useful commands
99

@@ -12,14 +12,14 @@ Please check the [pyproject.toml](https://github.com/commitizen-tools/commitizen
1212
### Code Changes
1313

1414
```bash
15-
# Ensure you have the correct dependencies, for nix user's see below
16-
poetry install
15+
# Ensure you have the correct dependencies
16+
uv sync --dev
1717

1818
# Make ruff happy
19-
poetry format
19+
uv run poe format
2020

2121
# Check if ruff and mypy are happy
22-
poetry lint
22+
uv run poe lint
2323

2424
# Check if mypy is happy in python 3.10
2525
mypy --python-version 3.10
@@ -33,16 +33,5 @@ pytest -n auto <test_suite>
3333

3434
```bash
3535
# Build the documentation locally and check for broken links
36-
poetry doc
37-
```
38-
39-
### Nix Users
40-
41-
If you are using Nix, you can install poetry locally by running:
42-
43-
```sh
44-
python -m venv .venv
45-
. .venv/bin/activate
46-
pip install -U pip && pip install poetry
47-
poetry install
36+
uv run poe doc
4837
```

0 commit comments

Comments
 (0)