Skip to content

Commit ef3cac6

Browse files
committed
migrate to uv
Signed-off-by: rafsaf <[email protected]>
1 parent 3485a74 commit ef3cac6

File tree

8 files changed

+1020
-2001
lines changed

8 files changed

+1020
-2001
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: uv
44
directory: /
55
schedule:
66
interval: monthly
7-
open-pull-requests-limit: 5
7+
open-pull-requests-limit: 1
88
allow:
99
- dependency-type: "all"
1010
groups:

.github/workflows/tests.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,27 @@ jobs:
2222
ports:
2323
- 5432:5432
2424
steps:
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v5
2626

27-
- name: Set up Python
28-
uses: actions/setup-python@v5
27+
- name: "Set up Python"
28+
uses: actions/setup-python@v6
2929
with:
30-
python-version: "3.13.1"
30+
python-version-file: "pyproject.toml"
3131

32-
- name: Install Poetry
33-
uses: snok/install-poetry@v1
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v7
3434
with:
35-
virtualenvs-create: true
36-
virtualenvs-in-project: false
37-
virtualenvs-path: /opt/venv
35+
version: "0.9.2"
36+
enable-cache: true
3837

39-
- name: Load cached venv
40-
id: cached-poetry-dependencies
41-
uses: actions/cache@v4
42-
with:
43-
path: /opt/venv
44-
key: venv-${{ runner.os }}-python-3.13.1-${{ hashFiles('poetry.lock') }}
45-
46-
- name: Install dependencies and actiavte virtualenv
47-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
48-
run: |
49-
poetry install --no-interaction --no-root
38+
- name: Install the project
39+
run: uv sync --locked --all-extras --dev
40+
shell: bash
5041

5142
- name: Run tests
5243
env:
5344
SECURITY__JWT_SECRET_KEY: very-not-secret
5445
DATABASE__HOSTNAME: localhost
5546
DATABASE__PASSWORD: postgres
5647
run: |
57-
poetry run pytest
48+
uv run pytest

.github/workflows/type_check.yml

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,23 @@ jobs:
1414

1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818

19-
- name: Set up Python
20-
uses: actions/setup-python@v5
19+
- name: "Set up Python"
20+
uses: actions/setup-python@v6
2121
with:
22-
python-version: "3.13.1"
22+
python-version-file: "pyproject.toml"
2323

24-
- name: Install Poetry
25-
uses: snok/install-poetry@v1
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v7
2626
with:
27-
virtualenvs-create: true
28-
virtualenvs-in-project: true
27+
version: "0.9.2"
28+
enable-cache: true
2929

30-
- name: Install Poetry
31-
uses: snok/install-poetry@v1
32-
with:
33-
virtualenvs-create: true
34-
virtualenvs-in-project: false
35-
virtualenvs-path: /opt/venv
36-
37-
- name: Load cached venv
38-
id: cached-poetry-dependencies
39-
uses: actions/cache@v4
40-
with:
41-
path: /opt/venv
42-
key: venv-${{ runner.os }}-python-3.13.1-${{ hashFiles('poetry.lock') }}
43-
44-
- name: Install dependencies and actiavte virtualenv
45-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
46-
run: |
47-
poetry install --no-interaction --no-root
30+
- name: Install the project
31+
run: uv sync --locked --all-extras --dev
32+
shell: bash
4833

4934
- name: Run ${{ matrix.check }}
5035
run: |
51-
poetry run ${{ matrix.check }} .
36+
uv run ${{ matrix.check }} .

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ ENV PYTHONUNBUFFERED=1
44
WORKDIR /build
55

66
# Create requirements.txt file
7-
FROM base AS poetry
8-
RUN pip install poetry==2.1.3
9-
RUN poetry self add poetry-plugin-export
10-
COPY poetry.lock pyproject.toml ./
11-
RUN poetry export -o /requirements.txt --without-hashes
7+
FROM base AS uv
8+
COPY --from=ghcr.io/astral-sh/uv:0.9.2 /uv /uvx /bin/
9+
COPY uv.lock pyproject.toml ./
10+
RUN uv export --no-dev --no-hashes -o /requirements.txt --no-install-workspace --frozen
11+
RUN uv export --only-group dev --no-hashes -o /requirements-dev.txt --no-install-workspace --frozen
1212

1313
FROM base AS final
14-
COPY --from=poetry /requirements.txt .
14+
COPY --from=uv /requirements.txt .
1515

1616
# Create venv, add it to path and install requirements
1717
RUN python -m venv /venv

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ _Check out online example: https://minimal-fastapi-postgres-template.rafsaf.pl,
1212
- [Features](#features)
1313
- [Quickstart](#quickstart)
1414
- [1. Create repository from a template](#1-create-repository-from-a-template)
15-
- [2. Install dependecies with Poetry](#2-install-dependecies-with-poetry)
15+
- [2. Install dependecies with uv](#2-install-dependecies-with-uv)
1616
- [3. Setup database and migrations](#3-setup-database-and-migrations)
1717
- [4. Now you can run app](#4-now-you-can-run-app)
1818
- [5. Activate pre-commit](#5-activate-pre-commit)
@@ -38,7 +38,7 @@ _Check out online example: https://minimal-fastapi-postgres-template.rafsaf.pl,
3838
- [x] Full [Alembic](https://alembic.sqlalchemy.org/en/latest/) migrations setup
3939
- [x] Refresh token endpoint (not only access like in official template)
4040
- [x] Ready to go Dockerfile with [uvicorn](https://www.uvicorn.org/) webserver as an example
41-
- [x] [Poetry](https://python-poetry.org/docs/), `mypy`, `pre-commit` hooks with [ruff](https://github.com/astral-sh/ruff)
41+
- [x] [uv](https://docs.astral.sh/uv/getting-started/installation/), `mypy`, `pre-commit` hooks with [ruff](https://github.com/astral-sh/ruff)
4242
- [x] Perfect pytest asynchronous test setup with +40 tests and full coverage
4343

4444
<br>
@@ -55,16 +55,15 @@ _Check out online example: https://minimal-fastapi-postgres-template.rafsaf.pl,
5555

5656
See [docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
5757

58-
### 2. Install dependecies with [Poetry](https://python-poetry.org/docs/)
58+
### 2. Install dependecies with [uv](https://docs.astral.sh/uv/getting-started/installation/)
5959

6060
```bash
6161
cd your_project_name
6262

63-
### Poetry install (python3.13)
64-
poetry install
63+
uv sync
6564
```
6665

67-
Note, be sure to use `python3.13` with this template with either poetry or standard venv & pip, if you need to stick to some earlier python version, you should adapt it yourself (remove new versions specific syntax for example `str | int` for python < 3.10)
66+
Note, be sure to use `python3.13` with this template with either uv or standard venv & pip, if you need to stick to some earlier python version, you should adapt it yourself (remove new versions specific syntax for example `str | int` for python < 3.10)
6867

6968
### 3. Setup database and migrations
7069

0 commit comments

Comments
 (0)