Skip to content

Commit fac9aba

Browse files
committed
chore: replace poetry with uv
1 parent 8e52610 commit fac9aba

File tree

8 files changed

+796
-1274
lines changed

8 files changed

+796
-1274
lines changed

.github/workflows/main.yml

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,67 @@ on:
99

1010
env:
1111
IMAGE_NAME: unitystation/central-command
12+
UV_VERSION: "0.4.24"
1213

1314
jobs:
1415
lint:
1516
runs-on: ubuntu-latest
1617
steps:
1718
- uses: actions/checkout@v4
18-
- uses: actions/setup-python@v4
19+
- uses: astral-sh/setup-uv@v3
1920
with:
20-
python-version: '3.12'
21-
# because pre-commit uses external mypy
22-
- name: install mypy
23-
run: |
24-
pip install poetry
25-
poetry config virtualenvs.create false
26-
poetry install --only main,typecheck
21+
version: "0.4.24"
22+
enable-cache: true
23+
24+
- name: pre-commit cache key
25+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
26+
27+
- uses: actions/cache@v4
28+
with:
29+
path: ~/.cache/pre-commit
30+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
31+
32+
- name: Install Python
33+
run: uv python install
34+
35+
- name: install dependencies
36+
run: uv sync
37+
2738
# https://github.com/typeddjango/django-stubs/issues/458
2839
- name: create .env file
2940
run: cp example.env .env
30-
- uses: pre-commit/[email protected]
41+
42+
- name: pre-commit
43+
run: uv run pre-commit run --all-files
3144

3245
unit_test:
3346
needs: [ lint ]
3447
runs-on: ubuntu-latest
3548
steps:
3649
- uses: actions/checkout@v4
37-
- uses: actions/setup-python@v4
50+
- uses: astral-sh/setup-uv@v3
3851
with:
39-
python-version: '3.12'
40-
- name: Install dependencies
41-
run: |
42-
pip install poetry
43-
poetry config virtualenvs.create false
44-
poetry install --only main
52+
version: "0.4.24"
53+
enable-cache: true
54+
55+
- name: Set up Python
56+
run: uv python install
57+
58+
- name: install dependencies
59+
run: uv sync
60+
4561
- name: create .env file
4662
run: cp example.env .env
63+
4764
- name: Run tests
4865
env:
4966
SECRET_KEY: secret
5067
DB_ENGINE: django.db.backends.sqlite3
5168
run: |
5269
cd src
53-
python manage.py makemigrations --check
54-
python manage.py migrate
55-
python manage.py test tests/
70+
uv run manage.py makemigrations --check
71+
uv run manage.py migrate
72+
uv run manage.py test tests/
5673
5774
docker:
5875
needs: [ lint, unit_test ]

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
^.*.md$
1818
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.6.9
20+
rev: v0.7.0
2121
hooks:
2222
- id: ruff
2323
args: [ --fix ]

Dockerfile

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
FROM python:3.12-alpine3.20
22

3-
# in order:
4-
# proper stdout flushing for alpine
5-
# no .pyc files
6-
# do not store pip cache
7-
# do not check pip version
8-
# do not yell about root user
93
ENV PYTHONUNBUFFERED=yes \
104
PYTHONDONTWRITEBYTECODE=yes \
11-
PIP_NO_CACHE_DIR=1 \
12-
PIP_DISABLE_PIP_VERSION_CHECK=1 \
13-
PIP_ROOT_USER_ACTION=ignore
5+
UV_LINK_MODE=copy
146

157
WORKDIR /src
168

17-
COPY poetry.lock pyproject.toml ./
18-
19-
RUN : \
9+
RUN --mount=from=ghcr.io/astral-sh/uv:0.4.24,source=/uv,target=/bin/uv \
10+
--mount=type=cache,target=/root/.cache/uv \
11+
--mount=type=bind,source=uv.lock,target=uv.lock \
12+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
2013
# psycopg runtime dep
21-
&& apk add --no-cache libpq \
22-
&& pip install poetry \
23-
&& poetry config virtualenvs.create false \
24-
&& poetry install --only main
14+
apk add --no-cache libpq \
15+
# export requirements from uv.lock since uv does not support sync withour venv
16+
&& uv export --frozen --format requirements-txt --no-dev --quiet | uv pip install --system -r -
2517

2618
COPY src .
2719

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Copy `example.env` to `.env` and customize it. You can then start development by
2424
You will need python 3.12+
2525

2626
<details>
27-
<summary>Extra steps if don't want to install poetry globally for some reason</summary>
27+
<summary>Extra steps if don't want to install uv globally for some reason</summary>
2828

2929
#### Install venv (only first time or after updating sytem python version)
3030

@@ -48,21 +48,22 @@ python -m venv .venv
4848

4949
#### Dependency installation
5050

51-
Install poetry to manage dependencies and update pip
51+
Install uv to manage dependencies
5252

5353
```sh
54-
pip install -U pip poetry
54+
pip install -U pip uv
5555
```
5656

5757
Install dev dependencies
5858

5959
```sh
60-
poetry install
60+
uv sync
6161
```
6262

6363
#### Start the server
6464

6565
from the src folder run
66+
6667
```sh
6768
python manage.py runserver
6869
```

0 commit comments

Comments
 (0)