Skip to content

Commit b5be8a4

Browse files
authored
Migrate to uv (#38)
* Update pyproject.toml for uv * Integrate tox with uv * Update Makefile commands * Update remaining references to poetry * Add workaround to calculate package version for docs * Remove `make update-dependencies` * trigger CI
1 parent 679eaad commit b5be8a4

18 files changed

+132
-120
lines changed

.github/workflows/python-code-style.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
uses: actions/setup-python@v5
2222
with:
2323
python-version: "3.13"
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
2426
- name: Install dependencies
2527
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install poetry tox
28-
make poetry-export
28+
make dev-dependencies
2929
- name: Check code style with black
3030
run: |
3131
make format

.github/workflows/python-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
uses: actions/setup-python@v5
2222
with:
2323
python-version: "3.13"
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
2426
- name: Install dependencies
2527
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install poetry tox
28-
make poetry-export
28+
make dev-dependencies
2929
- name: Lint with ruff
3030
run: make lint

.github/workflows/python-quality.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ jobs:
2121
uses: actions/setup-python@v5
2222
with:
2323
python-version: "3.13"
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
2426
- name: Install dependencies
2527
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install poetry
28-
poetry config virtualenvs.create false
29-
poetry install --no-root --with dev
28+
make dev-dependencies
3029
- name: Test & publish code coverage
3130
uses: paambaati/[email protected]
3231
env:

.github/workflows/python-tests.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ jobs:
2828
uses: actions/setup-python@v5
2929
with:
3030
python-version: "${{ matrix.version }}"
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v6
3133
- name: Install dependencies
3234
run: |
33-
python -m pip install --upgrade pip
34-
python -m pip install poetry
35-
poetry config virtualenvs.create false
36-
poetry install --no-root --with dev
35+
make dev-dependencies
3736
- name: Test with pytest
3837
id: citest
3938
run: |
@@ -68,7 +67,7 @@ jobs:
6867
--body "$BODY")
6968
if [[ $PINNED == true ]]; then
7069
gh issue pin "$new_issue_url"
71-
fi
70+
fi
7271
fi
7372
env:
7473
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/python-typing.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
uses: actions/setup-python@v5
2222
with:
2323
python-version: "3.13"
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
2426
- name: Install dependencies
2527
run: |
26-
python -m pip install --upgrade pip
27-
python -m pip install poetry tox
28-
make poetry-export
28+
make dev-dependencies
2929
- name: Check typing
3030
run: make typing

.github/workflows/release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ jobs:
2222
with:
2323
python-version: "3.13"
2424

25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v6
2527
- name: Install dependencies
2628
run: |
27-
python -m pip install --upgrade pip
28-
python -m pip install poetry poetry-dynamic-versioning
29+
make dev-dependencies
2930
3031
- name: Build package
3132
run: |
32-
poetry build
33+
uv build
3334
3435
- name: Archive the dist folder
3536
uses: actions/upload-artifact@v4

.github/workflows/reusable-github-pages.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ jobs:
4646

4747
# Here we want to install the current package in editable mode,
4848
# in case mkdocs needs the package (i.e. we are building a mkdocs plugin).
49+
- name: Install uv
50+
uses: astral-sh/setup-uv@v6
4951
- name: Install dependencies
5052
run: |
51-
python -m pip install --upgrade pip
52-
python -m pip install poetry
53-
poetry config virtualenvs.create false
54-
poetry install --with dev
53+
make dev-dependencies
5554
5655
- name: Configure Git user
5756
run: |
@@ -64,12 +63,12 @@ jobs:
6463
6564
- name: Build and deploy static pages
6665
run: |
67-
mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}
66+
uv run mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}
6867
6968
- name: Set default site version
7069
if: ${{ inputs.set-default }}
7170
run: |
72-
mike set-default ${{ inputs.site-version }} --push --branch ${{ inputs.branch }}
71+
uv run mike set-default ${{ inputs.site-version }} --push --branch ${{ inputs.branch }}
7372
7473
# `mike` is specifically built to be used together with GitHub pages.
7574
# To upload the website to another service (i.e. AWS S3) uncomment

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,5 @@ dmypy.json
282282

283283
# Cython debug symbols
284284
cython_debug/
285-
poetry.lock
285+
uv.lock
286+
version.py

.idea/bootstrap-python-package.iml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Please note that this project is released with a Contributor Code of Conduct. By
88

99
## Submitting a pull request
1010

11+
Before running any commands, [install `uv`](https://docs.astral.sh/uv/getting-started/installation/):
12+
1113
0. Fork and clone the repository
12-
0. Install poetry: `pip install -g poetry`
1314
0. Configure and install the dependencies: `make dev-dependencies`
1415
0. Make sure the tests pass on your machine: `make check`
1516
0. Create a new branch: `git checkout -b my-branch-name`

Makefile

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,41 @@
1-
.PHONY: dev-dependencies update-dependencies test docs fix check typing lint format ci-test ci-coverage poetry-export
1+
.PHONY: dev-dependencies update-dependencies test docs fix check typing lint format ci-test ci-coverage
22

33
#########################
44
###### dev commands #####
55
#########################
66
dev-dependencies:
7-
poetry install --with dev --no-root
8-
9-
update-dependencies:
10-
poetry update --with dev
7+
uv lock --upgrade
8+
uv sync --all-groups --frozen
119

1210
test:
13-
poetry run pytest -n auto --cov
11+
uv run pytest -n auto --cov
1412

1513
docs:
16-
poetry run mkdocs serve
14+
uv run mkdocs serve
1715

1816
fix:
19-
poetry run ruff check . --fix
20-
poetry run ruff format .
21-
22-
check: poetry-export
23-
tox
24-
25-
typing: poetry-export
26-
tox -e typing
17+
uv run ruff format .
18+
uv run ruff check . --fix
19+
uv run ruff format .
2720

28-
lint: poetry-export
29-
tox -e lint
21+
check:
22+
uv run tox
3023

31-
format: poetry-export
32-
tox -e format
24+
typing:
25+
uv run tox -e typing
3326

27+
lint:
28+
uv run tox -e lint
3429

35-
#########################
36-
#### Helper commands ####
37-
#########################
38-
poetry-export:
39-
poetry export -f requirements.txt --output /tmp/requirements.txt --with dev
30+
format:
31+
uv run tox -e format
4032

4133

4234
#########################
4335
###### CI commands ######
4436
#########################
4537
ci-test:
46-
poetry run pytest
38+
uv run pytest
4739

4840
ci-coverage:
49-
poetry run pytest --cov --cov-report lcov
41+
uv run pytest --cov --cov-report lcov

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ It is configured with all the following features:
4343
* Update the PyCharm Copyright profile in the IDE settings: Editor | Copyright | Copyright Profiles (if you want to use it)
4444
* Setup local development:
4545
* Clone the repository
46-
* Install poetry `pip install poetry`
46+
* [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
4747
* Install dev dependencies with `make dev-dependencies`
4848
* (optional) It is strongly recommended to install [pre-commit](https://pre-commit.com/#installation)
4949
and run `pre-commit install` so that formatting and linting are automatically executed during `git commit`.
5050
* Setup GitHub pages (this need local development setup):
51-
* Initialise documentation branch `poetry run mike deploy dev latest --update-aliases --push`
51+
* Initialise documentation branch `uv run mike deploy dev latest --update-aliases --push`
5252
* Configure GitHub Pages to deploy from the `gh-pages` branch (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/pages`)
5353
* Add the `main` branch and the `v*.*.*` tag rules to the "deployment branches and tags" list in the `gh-pages` environment (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/environments`)
5454

@@ -59,7 +59,7 @@ and remove the marked lines in `workflows/release.yml`.
5959

6060
## Package release
6161

62-
This setup uses [poetry-dynamic-versioning](https://github.com/mtkennerly/poetry-dynamic-versioning).
62+
This setup uses [uv-dynamic-versioning](https://github.com/ninoseki/uv-dynamic-versioning/tree/main).
6363
This means it's not necessary to commit the version in the code but the CI pipeline
6464
will infer it from the git tag.
6565

@@ -72,14 +72,13 @@ To release a new version, just create a new release and tag in the GitHub reposi
7272
the convention `vX.X.X` (semantic versioning preceded by lowercase `v`). It will publish
7373
the correct version on Pypi, omitting the `v` (ie. `v1.0.0` will publish `1.0.0`).
7474

75-
This format can be customized, refer to [poetry-dynamic-versioning docs](https://github.com/mtkennerly/poetry-dynamic-versioning)
75+
This format can be customized, refer to [uv-dynamic-versioning docs](https://github.com/ninoseki/uv-dynamic-versioning/tree/main).
7676

7777
## Commands for development
7878

7979
All the common commands used during development can be run using make targets:
8080

8181
* `make dev-dependencies`: Install dev requirements
82-
* `make update-dependencies`: Update dev requirements
8382
* `make fix`: Run code style and lint automatic fixes (where possible)
8483
* `make test`: Run test suite against system python version
8584
* `make check`: Run tests against all available python versions, code style and lint checks

bootstrap_python_package/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ==============================================================================
2-
# Copyright (c) 2024 Federico Busetti =
2+
# Copyright (c) 2025 Federico Busetti =
33
44
# =
55
# Permission is hereby granted, free of charge, to any person obtaining a =
@@ -21,9 +21,6 @@
2121
# DEALINGS IN THE SOFTWARE. =
2222
# ==============================================================================
2323

24-
__version__ = "0.0.0"
25-
__version_tuple__ = (0, 0, 0)
26-
2724

2825
def some_function() -> str:
2926
"""

0 commit comments

Comments
 (0)