Skip to content

Commit 56244a5

Browse files
author
Piotr Rarus
committed
Switch poetry to uv
1 parent 7d23651 commit 56244a5

File tree

12 files changed

+510
-729
lines changed

12 files changed

+510
-729
lines changed

.flake8

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ jobs:
1111
- name: Checkout repository
1212
uses: actions/checkout@v4
1313

14+
- name: Install UV
15+
uses: astral-sh/setup-uv@v5
16+
with:
17+
version: "0.6.5"
18+
enable-cache: true
19+
cache-dependency-glob: "uv.lock"
20+
1421
- name: Install Poetry
1522
uses: snok/install-poetry@v1
1623
with:
1724
virtualenvs-in-project: true
1825
virtualenvs-path: .venv
1926

20-
- name: Set up Python 3.11
21-
uses: actions/setup-python@v5
22-
with:
23-
python-version: '3.11'
24-
cache: 'poetry'
27+
- name: Set up Python 3.12
28+
run: uv python install
2529

2630
- name: Cache pre-commit
2731
uses: actions/cache@v4
@@ -36,26 +40,25 @@ jobs:
3640
key: mypy_cache-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
3741

3842
- name: Install dependencies
39-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
40-
run: poetry install --no-interaction --no-root --with dev
43+
run: uv sync --all-extras --test
4144

4245
- name: pre-commit
4346
run: |
44-
poetry run pre-commit run -a
47+
uv run pre-commit run -a
4548
4649
- name: Mypy
4750
run: |
48-
poetry run mypy --incremental --no-install-types --show-error-codes --pretty src tests
51+
uv run mypy --incremental --no-install-types --show-error-codes --pretty src tests
4952
5053
- name: Tests
5154
run: |
52-
poetry run coverage run -m pytest --cov-config=.coveragerc
55+
uv run coverage run -m pytest --cov-config=.coveragerc
5356
5457
- name: Tests coverage
5558
run: |
56-
poetry run coverage html
57-
poetry run coverage xml
58-
poetry run coverage report --show-missing
59+
uv run coverage html
60+
uv run coverage xml
61+
uv run coverage report --show-missing
5962
6063
# Requires CODECOV_TOKEN in repository secrets
6164
- name: Upload codecov

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ ipython_config.py
9494
# install all needed dependencies.
9595
#Pipfile.lock
9696

97-
# poetry
98-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99-
# This is especially recommended for binary packages to ensure reproducibility, and is more
100-
# commonly ignored for libraries.
101-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102-
#poetry.lock
103-
10497
# pdm
10598
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
10699
#pdm.lock

.pre-commit-config.yaml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
exclude: '.git|.tox'
2-
default_stages: [commit]
2+
default_stages: [pre-commit]
33
fail_fast: true
44

55
repos:
@@ -24,44 +24,32 @@ repos:
2424
hooks:
2525
- id: codespell
2626
name: codespell
27-
entry: poetry run codespell
27+
entry: uv run codespell
2828
language: system
2929
types_or: [python, rst, markdown]
3030
files: ^src/
3131

3232
- id: isort
3333
name: isort
34-
entry: poetry run isort
34+
entry: uv run isort
3535
language: system
3636
files: ^src/
3737

3838
- id: pyupgrade
3939
name: pyupgrade
40-
entry: poetry run pyupgrade
40+
entry: uv run pyupgrade
4141
language: system
4242
args: [--py311-plus]
4343
files: ^src/
4444

45-
- id: yesqa
46-
name: yesqa
47-
entry: poetry run yesqa
48-
language: system
49-
files: ^src/
50-
5145
- id: black
5246
name: black
53-
entry: poetry run black
47+
entry: uv run black
5448
language: system
5549
files: ^src/
5650

5751
- id: ruff
5852
name: ruff
59-
entry: poetry run ruff
60-
language: system
61-
files: ^src/
62-
63-
- id: flake8
64-
name: flake8
65-
entry: poetry run flake8
53+
entry: uv run ruff check
6654
language: system
6755
files: ^src/

Makefile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
1+
.PHONY: venv sync update lock format lint test test_cov build
2+
13
# Creates a virtual environment and installs dependencies for local development.
24
venv:
3-
poetry install --no-root
4-
poetry run pre-commit install
5+
uv sync --all-groups --all-extras --frozen --reinstall
6+
7+
# Syncs the dependencies for local development.
8+
sync:
9+
uv sync --all-groups --all-extras
10+
11+
# Updates the dependencies to the latest versions.
12+
update:
13+
uv sync --all-groups --all-extras --upgrade
514

615
# Locks the versions of project dependencies for consistency.
716
lock:
8-
poetry lock --no-update
17+
uv lock
918

1019
# Formats code using isort and black for consistent style.
1120
format:
12-
poetry run isort src
13-
poetry run black --config pyproject.toml src
21+
uv run isort src
22+
uv run black --config pyproject.toml src
1423

1524
# Runs all linters to catch potential issues and enforce style.
1625
lint:
17-
poetry run pre-commit run -a
18-
poetry run ruff check src
19-
poetry run flake8 src
20-
poetry run mypy --incremental --no-install-types --show-error-codes --pretty src
26+
uv run pre-commit run -a
27+
uv run mypy --incremental --no-install-types --show-error-codes --pretty src
2128

2229
# Runs pytest tests to ensure code correctness.
2330
test:
24-
poetry run pytest
31+
uv run pytest
2532

2633
# Runs tests with coverage and generates a report.
2734
test_cov:
28-
poetry run coverage run -m pytest src --cov-config=.coveragerc
29-
poetry run coverage html
30-
poetry run coverage xml
31-
poetry run coverage report --show-missing
35+
uv run coverage run -m pytest src --cov-config=.coveragerc
36+
uv run coverage html
37+
uv run coverage xml
38+
uv run coverage report --show-missing
3239

3340
# Runs pre-commit hooks, mypy checks, and tests. Quite useful before pushing changes.
3441
build: format lint test

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ This is a template repository dedicated to `Python` projects. It provides some b
1515

1616
## Prerequisites
1717

18-
In order to use this template, you need to have both `poetry` and `make` installed.
18+
In order to use this template, you need to have both `uv` and `make` installed.
1919

20-
### Poetry
20+
### uv
2121

22-
`poetry` is a package manager we're using. You can check the installation instructions [here](https://python-poetry.org/docs/#installing-with-the-official-installer). You should avoid installing `poetry` through `pip` as it is a system-level tool, separated from the `Python` runtime you're currently using. It enables us to treat `Python` as any other dependency and pin its version in `pyproject.toml`.
22+
`uv` is a package manager we're using. You can check the installation instructions [here](https://docs.astral.sh/uv/getting-started/installation/). You should avoid installing `poetry` through `pip` as it is a system-level tool, separated from the `Python` runtime you're currently using. It enables us to treat `Python` as any other dependency and pin its version in `pyproject.toml`.
2323

2424
```sh
25-
curl -sSL https://install.python-poetry.org | python3 -
25+
curl -LsSf https://astral.sh/uv/install.sh | sh
2626
```
2727

2828
### make
@@ -82,16 +82,14 @@ make build # format lint test
8282
- `.pre-commit-config.yaml` - pre-commit pipeline configuration
8383
- `Makefile` - tasks definitions, much simpler to call `make` than writing whole commands in the terminal; it's also easy to check what project-specific functionalities you're exposing
8484
- `mypy.ini` - `mypy` config, usually some of your dependencies won't be hinted so you're gonna ignore them here
85-
- `poetry.lock` - compiled dependencies
86-
- `poetry.toml` - `poetry` config, as you shouldn't enforce other devs where to put their virtual environment this must be a separate config file
85+
- `uv.lock` - compiled dependencies
8786
- `pyproject.toml` - repo config
8887

8988
## Tools
9089

9190
When developing a project there's a need to automate some tedious stuff that helps you keep the repo clean and check it against common standards. These include managing the environment, dependencies, syntax, etc.
9291

93-
- [poetry](https://github.com/python-poetry/poetry)
94-
- [flake8](https://github.com/PyCQA/flake8)
92+
- [uv](https://github.com/astral-sh/uv)
9593
- [isort](https://github.com/PyCQA/isort)
9694
- [ruff](https://github.com/charliermarsh/ruff)
9795
- [black](https://github.com/psf/black)

0 commit comments

Comments
 (0)