Skip to content

Migrate to uv #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/python-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry tox
make poetry-export
make dev-dependencies
- name: Check code style with black
run: |
make format
6 changes: 3 additions & 3 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry tox
make poetry-export
make dev-dependencies
- name: Lint with ruff
run: make lint
7 changes: 3 additions & 4 deletions .github/workflows/python-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --no-root --with dev
make dev-dependencies
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v9.0.0
env:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.version }}"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --no-root --with dev
make dev-dependencies
- name: Test with pytest
id: citest
run: |
Expand Down Expand Up @@ -68,7 +67,7 @@ jobs:
--body "$BODY")
if [[ $PINNED == true ]]; then
gh issue pin "$new_issue_url"
fi
fi
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry tox
make poetry-export
make dev-dependencies
- name: Check typing
run: make typing
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ jobs:
with:
python-version: "3.13"

- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry poetry-dynamic-versioning
make dev-dependencies

- name: Build package
run: |
poetry build
uv build

- name: Archive the dist folder
uses: actions/upload-artifact@v4
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/reusable-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ jobs:

# Here we want to install the current package in editable mode,
# in case mkdocs needs the package (i.e. we are building a mkdocs plugin).
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --with dev
make dev-dependencies

- name: Configure Git user
run: |
Expand All @@ -64,12 +63,12 @@ jobs:

- name: Build and deploy static pages
run: |
mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}
uv run mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}

- name: Set default site version
if: ${{ inputs.set-default }}
run: |
mike set-default ${{ inputs.site-version }} --push --branch ${{ inputs.branch }}
uv run mike set-default ${{ inputs.site-version }} --push --branch ${{ inputs.branch }}

# `mike` is specifically built to be used together with GitHub pages.
# To upload the website to another service (i.e. AWS S3) uncomment
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,5 @@ dmypy.json

# Cython debug symbols
cython_debug/
poetry.lock
uv.lock
version.py
3 changes: 2 additions & 1 deletion .idea/bootstrap-python-package.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Please note that this project is released with a Contributor Code of Conduct. By

## Submitting a pull request

Before running any commands, [install `uv`](https://docs.astral.sh/uv/getting-started/installation/):

0. Fork and clone the repository
0. Install poetry: `pip install -g poetry`
0. Configure and install the dependencies: `make dev-dependencies`
0. Make sure the tests pass on your machine: `make check`
0. Create a new branch: `git checkout -b my-branch-name`
Expand Down
44 changes: 18 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
.PHONY: dev-dependencies update-dependencies test docs fix check typing lint format ci-test ci-coverage poetry-export
.PHONY: dev-dependencies update-dependencies test docs fix check typing lint format ci-test ci-coverage

#########################
###### dev commands #####
#########################
dev-dependencies:
poetry install --with dev --no-root

update-dependencies:
poetry update --with dev
uv lock --upgrade
uv sync --all-groups --frozen

test:
poetry run pytest -n auto --cov
uv run pytest -n auto --cov

docs:
poetry run mkdocs serve
uv run mkdocs serve

fix:
poetry run ruff check . --fix
poetry run ruff format .

check: poetry-export
tox

typing: poetry-export
tox -e typing
uv run ruff format .
uv run ruff check . --fix
uv run ruff format .

lint: poetry-export
tox -e lint
check:
uv run tox

format: poetry-export
tox -e format
typing:
uv run tox -e typing

lint:
uv run tox -e lint

#########################
#### Helper commands ####
#########################
poetry-export:
poetry export -f requirements.txt --output /tmp/requirements.txt --with dev
format:
uv run tox -e format


#########################
###### CI commands ######
#########################
ci-test:
poetry run pytest
uv run pytest

ci-coverage:
poetry run pytest --cov --cov-report lcov
uv run pytest --cov --cov-report lcov
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ It is configured with all the following features:
* Update the PyCharm Copyright profile in the IDE settings: Editor | Copyright | Copyright Profiles (if you want to use it)
* Setup local development:
* Clone the repository
* Install poetry `pip install poetry`
* [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
* Install dev dependencies with `make dev-dependencies`
* (optional) It is strongly recommended to install [pre-commit](https://pre-commit.com/#installation)
and run `pre-commit install` so that formatting and linting are automatically executed during `git commit`.
* Setup GitHub pages (this need local development setup):
* Initialise documentation branch `poetry run mike deploy dev latest --update-aliases --push`
* Initialise documentation branch `uv run mike deploy dev latest --update-aliases --push`
* Configure GitHub Pages to deploy from the `gh-pages` branch (at URL `https://github.com/GITHUB_NAME_OR_ORGANIZATION/GITHUB_REPOSITORY/settings/pages`)
* 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`)

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

## Package release

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

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

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

## Commands for development

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

* `make dev-dependencies`: Install dev requirements
* `make update-dependencies`: Update dev requirements
* `make fix`: Run code style and lint automatic fixes (where possible)
* `make test`: Run test suite against system python version
* `make check`: Run tests against all available python versions, code style and lint checks
Expand Down
5 changes: 1 addition & 4 deletions bootstrap_python_package/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ==============================================================================
# Copyright (c) 2024 Federico Busetti =
# Copyright (c) 2025 Federico Busetti =
# <729029+febus982@users.noreply.github.com> =
# =
# Permission is hereby granted, free of charge, to any person obtaining a =
Expand All @@ -21,9 +21,6 @@
# DEALINGS IN THE SOFTWARE. =
# ==============================================================================

__version__ = "0.0.0"
__version_tuple__ = (0, 0, 0)


def some_function() -> str:
"""
Expand Down
Loading