Skip to content

Commit 002b813

Browse files
authored
Build: migrate to uv (#119)
* 패키지 관리를 poetry에서 uv로 변경했습니다.
1 parent cf7354a commit 002b813

File tree

7 files changed

+1676
-2992
lines changed

7 files changed

+1676
-2992
lines changed

.github/workflows/test.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,19 @@ jobs:
3030
- name: change mysql charset
3131
run: mysql -h 127.0.0.1 -P 3307 -u root -p'root-password' -e "ALTER DATABASE testdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
3232

33-
- uses: actions/setup-python@v4
33+
- name: Setup uv
34+
uses: astral-sh/setup-uv@v3
3435
with:
3536
python-version: 3.11
37+
enable-cache: true
3638

37-
- name: Install poetry
38-
run: pipx install poetry --python python3.11
39-
40-
- name: Set poetry environment & install dependencies
41-
run: |
42-
poetry config virtualenvs.in-project true
43-
poetry env use 3.11
44-
poetry install --no-root
39+
- name: Install dependencies
40+
run: uv sync --frozen
4541

4642
- name: Run tests
4743
run: |
4844
cd ${GITHUB_WORKSPACE}/wacruit/
49-
poetry run pytest --junit-xml=${GITHUB_WORKSPACE}/wacruit/test.xml ./
45+
uv run pytest --junit-xml=${GITHUB_WORKSPACE}/wacruit/test.xml ./
5046
5147
- name: Test reports
5248
uses: dorny/test-reporter@v1
@@ -61,10 +57,10 @@ jobs:
6157
- name: Run pre-commit
6258
run: |
6359
git fetch origin ${{ github.base_ref }}
64-
poetry run pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD
60+
uv run pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD
6561
6662
- name: Run alembic migration test
6763
run: |
6864
mkdir -p wacruit/src/database/migrations/versions
69-
ls wacruit/src/database/migrations/versions/* || poetry run alembic revision --autogenerate
70-
poetry run alembic upgrade head
65+
ls wacruit/src/database/migrations/versions/* || uv run alembic revision --autogenerate
66+
uv run alembic upgrade head

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
FROM python:3.11-bookworm as builder
1+
FROM python:3.11-bookworm AS builder
22

3-
RUN pip install poetry==1.5.0
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
44

5-
ENV POETRY_NO_INTERACTION=1 \
6-
POETRY_VIRTUALENVS_IN_PROJECT=1 \
7-
POETRY_VIRTUALENVS_CREATE=1 \
8-
POETRY_CACHE_DIR=/tmp/poetry_cache
5+
ENV UV_COMPILE_BYTECODE=1 \
6+
UV_HTTP_TIMEOUT=300 \
7+
UV_LINK_MODE=copy \
8+
UV_PROJECT_ENVIRONMENT=/app/.venv
99

1010
WORKDIR /app
1111

12-
COPY pyproject.toml poetry.lock ./
12+
COPY pyproject.toml uv.lock ./
1313

14-
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root
14+
RUN --mount=type=cache,target=/root/.cache/uv \
15+
uv sync --frozen --no-dev --no-install-project
1516

16-
FROM python:3.11-slim-bookworm as runtime
17+
FROM python:3.11-slim-bookworm AS runtime
1718

1819
ARG ENV
1920

2021
ENV VIRTUAL_ENV=/app/.venv \
2122
PATH="/app/.venv/bin:$PATH" \
22-
env=$ENV
23+
env=$ENV \
24+
PYTHONUNBUFFERED=1
25+
26+
WORKDIR /app
2327

2428
RUN apt-get update && apt-get install -y --no-install-recommends \
2529
libmariadb-dev \

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Prerequisites
77

88
- Python version 3.11 and above is required.
9-
- Install [Poetry](https://python-poetry.org/docs/#installation) package manager to install all the dependencies.
9+
- Install [uv](https://docs.astral.sh/uv/getting-started/installation/) package manager to install all the dependencies.
1010
- A MySQL client is required for database operations in your local machine. On macos, you can install via `brew install mysql-client` or `brew install mysql`. Don't forget to add it to PATH.
1111
- This project requires [wacruit-judge](https://github.com/wafflestudio/wacruit-judge) which is the fork version of [Judge0](https://github.com/judge0/judge0). To test this project, you first need to clone wacruit-judge and run it using docker-compose.
1212

@@ -16,10 +16,9 @@
1616

1717
Run the following command to install all the dependencies:
1818
```bash
19-
poetry config virtualenvs.in-project true
20-
poetry install
19+
uv sync
2120
```
22-
The above command will install all the required dependencies in a virtual environment. **Ensure that poetry have created `.venv` folder inside the project root. Otherwise pre-commit hooks won't work.**
21+
The above command will install all the required dependencies in a virtual environment.
2322

2423
### Pre-commit hooks
2524

0 commit comments

Comments
 (0)