Skip to content

Commit 6545cc3

Browse files
committed
migrating from poetry to uv
1 parent eb81d7d commit 6545cc3

File tree

9 files changed

+569
-880
lines changed

9 files changed

+569
-880
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test:
1919
--keep-project-on-failure -o /tmp .
2020

2121
cd /tmp/$(TARGET_NAME); \
22-
poetry run make lint && \
23-
poetry run make test && \
24-
poetry run make audit && \
22+
uv run make lint && \
23+
uv run make test && \
24+
uv run make audit && \
2525
echo '\nSuccess!'

README.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The article `How to Set up a Perfect Python Project <https://blog.pronus.xyz/en/
88
Features
99
--------
1010

11-
* Python 3.10+ (configurable)
12-
* Poetry_ based dependency management
11+
* Python 3.14+ (configurable)
12+
* uv_ based dependency management
1313
* Development tasks registered in a ``Makefile`` for easy access and management
1414
* Custom Mercurial/Git hooks for ``pre-commit`` and ``pre-push`` events
1515
* Linting based on ruff_, mypy_ and others
@@ -20,17 +20,17 @@ Instructions
2020
============
2121

2222
To instantiate the template into a new project, you'll need cookiecutter_ (>=2.4.0).
23-
The best way to use it just once is through pipx_:
23+
The best way to use it just once is through uvx_:
2424

2525
.. code:: console
2626
27-
$ pipx run cookiecutter gh:andredias/perfect_python_project
27+
$ uvx run cookiecutter gh:andredias/perfect_python_project
2828
29-
If you prefer, use can install it throught `pip` instead:
29+
If you prefer, use can install it throught ``uv tool`` instead:
3030

3131
.. code:: console
3232
33-
$ pip install --user cookiecutter
33+
$ uv tool install cookiecutter
3434
3535
Next, run the following command:
3636

@@ -58,7 +58,7 @@ That's it!
5858

5959
.. _cookiecutter: https://github.com/cookiecutter/cookiecutter
6060
.. _mypy: http://mypy-lang.org/
61-
.. _pipx: https://pypa.github.io/pipx/
62-
.. _Poetry: https://python-poetry.org/
6361
.. _pytest: https://pytest.org
6462
.. _ruff: https://pypi.org/project/ruff/
63+
.. _uv: https://docs.astral.sh/uv/
64+
.. _uvx: https://docs.astral.sh/uv/guides/tools/

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "",
33
"email": "",
4-
"project_name": "Perfect Python Project",
4+
"project_name": "Perfect_Python_Project",
55
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
66
"python_version": "3.12",
77
"line_length": 100,

hooks/post_gen_project.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
set -xuo pipefail
44

5-
poetry env use {{cookiecutter.python_version}}
6-
poetry lock --no-update
7-
poetry install
8-
poetry run make format
5+
uv sync --no-install-project
6+
uv run make format
97

108
commit_message="Initial project structure based on https://github.com/andredias/perfect_python_project/tree/master"
119

{{cookiecutter.project_slug}}/.github/workflows/continuous_integration.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,30 @@ jobs:
99
steps:
1010

1111
- name: Set up python
12-
uses: actions/setup-python@v4
12+
uses: actions/setup-python@v6
1313
with:
14-
python-version: '{{cookiecutter.python_version}}'
14+
python-version-file: "pyproject.toml"
1515

1616
- name: Check out repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v5
1818

19-
- name: Install Poetry
20-
uses: snok/install-poetry@v1
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
2121
with:
22-
virtualenvs-in-project: true
23-
24-
- name: Load cached venv
25-
id: cached-poetry-dependencies
26-
uses: actions/cache@v3
27-
with:
28-
path: .venv
29-
key: venv-{{ "${{ hashFiles('**/poetry.lock') }}" }}
22+
version: "0.9.8"
23+
enable-cache: true
3024

3125
- name: Install dependencies
32-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
33-
run: poetry install --no-interaction
26+
run: uv sync --locked --no-install-project
27+
28+
- name: Testing
29+
run: uv run --locked make test
3430

3531
- name: Linting
36-
run: poetry run make lint
32+
run: uv run --locked make lint
3733

3834
- name: Auditing
39-
run: poetry run make audit
35+
run: uv run make audit
4036

41-
- name: Test
42-
run: poetry run make test
37+
- name: Minimize uv cache
38+
run: uv cache prune --ci

{{cookiecutter.project_slug}}/poetry.lock

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

{{cookiecutter.project_slug}}/pyproject.toml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
[tool.poetry]
2-
name = "{{cookiecutter.project_name}}"
3-
version = "0.1.0"
1+
[project]
2+
name = "{{cookiecutter.project_slug}}"
43
description = ""
5-
authors = ["{{cookiecutter.author}} <{{cookiecutter.email}}>"]
6-
package-mode = false
7-
8-
[build-system]
9-
requires = ["poetry-core>=1.0.0"]
10-
build-backend = "poetry.core.masonry.api"
11-
12-
[tool.poetry.dependencies]
13-
python = "^{{cookiecutter.python_version}}"
14-
15-
[tool.poetry.group.dev.dependencies]
16-
mypy = "*"
17-
pip-audit = "*"
18-
pytest = "*"
19-
pytest-cov = "*"
20-
ruff = "*"
4+
authors = [
5+
{name="{{cookiecutter.author}}", email="{{cookiecutter.email}}"},
6+
]
7+
dynamic = ["version"]
8+
requires-python = "~={{cookiecutter.python_version}}.0"
9+
readme = "README.rst"
10+
11+
[dependency-groups]
12+
dev = [
13+
"mypy",
14+
"pip-audit",
15+
"pytest",
16+
"pytest-cov",
17+
"ruff",
18+
]
2119

2220
[tool.pytest.ini_options]
2321
filterwarnings = ["ignore::DeprecationWarning"]

{{cookiecutter.project_slug}}/scripts/install_hooks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
GIT_PRE_PUSH='#!/usr/bin/env bash
44
cd $(git rev-parse --show-toplevel)
5-
poetry run make lint && poetry run make test && poetry run make audit
5+
uv run --locked make lint && uv run --locked make test && uv run make audit
66
'
77

88
HG_HOOKS='[hooks]
9-
pre-push.lint_test = (cd `hg root`; poetry run make lint && poetry run make test && poetry run make audit)
9+
pre-push.lint_test = (cd `hg root`; uv run --locked make lint && uv run --locked make test && uv run make audit)
1010
'
1111

1212
if [ -d '.git' ]; then

0 commit comments

Comments
 (0)