Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:

- name: CI checks
run: |
python -m pip install wheel poetry
python -m pip install wheel uv
make
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.5.0

- Migrated from poetry to uv

## 0.4.2

- Upgraded all dependencies
Expand Down Expand Up @@ -124,7 +128,7 @@ First release. Contains support for:
- Run

```shell
VERSION=$( poetry version --short ) &&\
VERSION=$( python -m uv version --short --color never ) &&\
echo "Release: ${VERSION}" &&\
git tag -a ${VERSION} -m "Version ${VERSION}" &&\
git push --tags
Expand Down
36 changes: 15 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
ifeq (, $(shell which python))
$(error "No python on PATH.")
endif
POETRY_CMD := python -m poetry
ifeq (, $(shell $(POETRY_CMD)))
$(error "Poetry not available in Python installation.")
UV_CMD := python -m uv
ifeq (, $(shell $(UV_CMD) help))
$(error "uv not available in Python installation.")
endif

export LC_ALL = C
export LANG = C.UTF-8
PY_FILES := my_module tests
VERSION := $(shell poetry version --short)

# Bundle tasks

Expand All @@ -34,57 +33,52 @@ clean:
|xargs rm -rfv

clear-cache:
@echo Clear poetry cache
$(POETRY_CMD) cache clear pypi --all --no-interaction
@echo Clear dependency cache
$(UV_CMD) cache clean

venv: clean
@echo Initialize virtualenv, i.e., install required packages etc.
$(POETRY_CMD) config virtualenvs.in-project true --local
$(POETRY_CMD) install

shell:
@echo Open a new shell using virtualenv
$(POETRY_CMD) shell
$(UV_CMD) sync

# Building software

build: test mypy isort black lint
@echo Run build process to package application
$(POETRY_CMD) build
$(UV_CMD) build

test:
@echo Run all tests suites
$(POETRY_CMD) run py.test tests
$(UV_CMD) run py.test tests

mypy:
@echo Run static code checks against source code base
$(POETRY_CMD) run mypy $(PY_FILES)
$(UV_CMD) run mypy $(PY_FILES)

isort:
@echo Check for incorrectly sorted imports
$(POETRY_CMD) run isort --check-only $(PY_FILES)
$(UV_CMD) run isort --check-only $(PY_FILES)

isort-apply:
@echo Check and correct incorrectly sorted imports
$(POETRY_CMD) run isort $(PY_FILES)
$(UV_CMD) run isort $(PY_FILES)

black:
@echo Run code formatting using black
$(POETRY_CMD) run black $(PY_FILES)
$(UV_CMD) run black $(PY_FILES)

lint:
@echo Run code formatting checks against source code base
$(POETRY_CMD) run flake8 $(PY_FILES)
$(UV_CMD) run flake8 $(PY_FILES)

outdated:
@echo Show outdated dependencies
$(POETRY_CMD) show --outdated
$(UV_CMD) pip list --outdated

# Executing

run-venv:
@echo Execute package directly in virtual environment
$(POETRY_CMD) run python -m my_module
$(UV_CMD) run python -m my_module

install-run:
@echo Install and run package via CLI using the activated Python env
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
## Setup

- Create a new repository [using this template](https://github.com/BastiTee/python-boilerplate/generate).
- Make sure that `python` is installed and available on system path. I _strongly_ recommend using [`pyenv`](https://github.com/pyenv/pyenv).
- Make sure [`poetry`](https://python-poetry.org/) is installed. This usually just means `python -m pip install poetry`.
- Make sure that `python` is installed and available on system path.
- Make sure [`uv`](https://github.com/astral-sh/uv) is installed. This usually just means `python -m pip install uv`.
- Rename the project using [the provided script](rename_template.sh): `./rename_template.sh`.
- Run `make` to initialize the project configuration and build everything.
- Refer to [the Makefile](Makefile) to learn about the various operations available. Most of them are just facades for `poetry`.
- Refer to [the Makefile](Makefile) to learn about the various operations available. Most of them are just facades for `uv`.

## Features

- Basic project/module organization according to <https://packaging.python.org>
- Makefile bootstrapping script
- [poetry](https://python-poetry.org/) with virtual environments and project builds
- [uv](https://github.com/astral-sh/uv) with virtual environments and project builds
- [black](https://github.com/psf/black) code formatting
- Unit testing with [pytest](https://docs.pytest.org/en/latest/)
- Linting ([flake8](http://flake8.pycqa.org)) and code formatting ([autopep8](https://github.com/hhatto/autopep8)) support
Expand Down
Loading