Skip to content

Commit 3e9f221

Browse files
chore(python): migrate to uv
1 parent b570437 commit 3e9f221

5 files changed

Lines changed: 991 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ concurrency:
1313
group: "${{ github.workflow }}-${{ github.ref }}"
1414
cancel-in-progress: true
1515

16+
env:
17+
PYTHON_VERSION: '3.14'
18+
1619
jobs:
1720
release-setup:
1821
name: Release Setup
@@ -48,14 +51,20 @@ jobs:
4851
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4952

5053
- name: Set up Python
54+
id: setup-python
5155
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
5256
with:
53-
python-version: "3.14"
57+
python-version: ${{ env.PYTHON_VERSION }}
58+
59+
- name: Set up uv
60+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
61+
with:
62+
enable-cache: true
5463

5564
- name: Install Python Dependencies
56-
run: |
57-
python -m pip install --upgrade pip setuptools wheel
58-
python -m pip install -e ".[dev]"
65+
env:
66+
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
67+
run: uv sync --locked --extra dev
5968

6069
- name: Test with pytest
6170
id: test
@@ -75,7 +84,7 @@ jobs:
7584
REDDIT_USERNAME: ${{ vars.REDDIT_USERNAME }}
7685
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
7786
shell: bash
78-
run: python -m pytest tests
87+
run: uv run --locked --extra dev pytest tests
7988

8089
- name: Upload test coverage
8190
# any except canceled or skipped

.replit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The command that is executed when the run button is clicked.
2-
run = ["python", "src/main.py"]
2+
run = ["uv", "run", "--locked", "python", "-m", "src"]
33

44
# The default file opened in the editor.
55
entrypoint = "README.md"

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax=docker/dockerfile:1
22
# artifacts: false
33
# platforms: linux/amd64
4-
FROM python:3.14-slim-bookworm
4+
FROM ghcr.io/astral-sh/uv:0.11-python3.14-bookworm-slim
55

66
# CI args
77
ARG BRANCH
@@ -12,14 +12,17 @@ ARG COMMIT
1212
ENV BRANCH=${BRANCH}
1313
ENV BUILD_VERSION=${BUILD_VERSION}
1414
ENV COMMIT=${COMMIT}
15+
ENV UV_PROJECT_ENVIRONMENT=/opt/venv
16+
ENV VIRTUAL_ENV=/opt/venv
17+
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
1518

1619
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1720

1821
VOLUME /data
1922
WORKDIR /app/
2023

2124
# Copy only necessary files for installation and runtime
22-
COPY pyproject.toml .
25+
COPY pyproject.toml uv.lock README.md ./
2326
COPY src/ src/
2427
COPY assets/ assets/
2528

@@ -44,11 +47,11 @@ __version__ = "${BUILD_VERSION}"
4447
EOF
4548

4649
# install python dependencies
47-
python -m pip install --no-cache-dir .
50+
uv sync --frozen --no-dev --no-install-project --python python --no-python-downloads
4851

4952
# set ownership of app and data directories
5053
mkdir -p /data
51-
chown -R supportbot:supportbot /app /data
54+
chown -R supportbot:supportbot /app /data "${VIRTUAL_ENV}"
5255
_SETUP
5356

5457
# switch to non-root user

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,25 @@ platforms such as GitHub discussions/issues might be added in the future.
7777
Install the project and its dependencies:
7878

7979
```bash
80-
python -m pip install -e .
80+
uv sync --locked
8181
```
8282

8383
For development (includes test dependencies):
8484

8585
```bash
86-
python -m pip install -e ".[dev]"
86+
uv sync --locked --extra dev
87+
```
88+
89+
Run tests:
90+
91+
```bash
92+
uv run --locked --extra dev pytest
8793
```
8894

8995
### Start
9096

9197
```bash
92-
python -m src
98+
uv run --locked python -m src
9399
```
94100

95101
* Invite bot to server:

0 commit comments

Comments
 (0)