Skip to content

Commit e8090ee

Browse files
authored
migrate to uv (#15)
Signed-off-by: rafsaf <rafal.safin12@gmail.com>
1 parent f7546cc commit e8090ee

File tree

8 files changed

+815
-1438
lines changed

8 files changed

+815
-1438
lines changed

.github/workflows/docker_build_and_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
docker_build_and_tests:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222

2323
- name: Set up QEMU
2424
uses: docker/setup-qemu-action@v3
@@ -49,7 +49,7 @@ jobs:
4949
id: cache
5050
with:
5151
path: cache-mount
52-
key: cache-mount-${{ runner.os }}-${{ hashFiles('Dockerfile') }}
52+
key: cache-mount-${{ runner.os }}-${{ hashFiles('Dockerfile', 'uv.lock') }}
5353
restore-keys: |
5454
cache-mount-${{ runner.os }}-
5555

.github/workflows/type_check.yml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,21 @@ jobs:
2121

2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v5
2525

26-
- name: Set up Python
26+
- name: "Set up Python"
2727
uses: actions/setup-python@v5
2828
with:
29-
python-version: "3.13.5"
29+
python-version-file: "pyproject.toml"
3030

31-
- name: Install Poetry
32-
uses: snok/install-poetry@v1
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v6
3333
with:
34-
virtualenvs-create: true
35-
virtualenvs-in-project: false
36-
virtualenvs-path: /opt/venv
34+
version: "0.9.2"
35+
enable-cache: true
3736

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

5040
- name: Run ${{ matrix.check }}
51-
run: |
52-
poetry run ${{ matrix.check }} .
41+
run: uv run ${{ matrix.check }} .

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ repos:
55
- id: check-yaml
66

77
- repo: https://github.com/astral-sh/ruff-pre-commit
8-
rev: v0.12.1
8+
rev: v0.14.5
99
hooks:
1010
- id: ruff-format
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.12.1
13+
rev: v0.14.5
1414
hooks:
1515
- id: ruff-check
1616
args: [--fix]

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
3737
# Clean up apt caches to reduce image size
3838
&& rm -rf /var/lib/apt/lists/*
3939

40-
FROM base AS poetry
41-
RUN --mount=type=cache,target=/root/.cache/pip pip install poetry==2.0.1
42-
RUN --mount=type=cache,target=/root/.cache/pip poetry self add poetry-plugin-export
43-
COPY poetry.lock pyproject.toml ./
44-
RUN poetry export -o /requirements.txt --without-hashes
45-
RUN poetry export -o /requirements-dev.txt --without-hashes --with dev
40+
FROM base AS uv
41+
COPY --from=ghcr.io/astral-sh/uv:0.9.2 /uv /uvx /bin/
42+
COPY uv.lock pyproject.toml ./
43+
RUN uv export --no-dev --no-hashes -o /requirements.txt --no-install-workspace --frozen
44+
RUN uv export --only-group dev --no-hashes -o /requirements-dev.txt --no-install-workspace --frozen
4645

4746
FROM base AS app
4847

49-
COPY --from=poetry /requirements.txt /requirements.txt
48+
COPY --from=uv /requirements.txt /requirements.txt
5049
RUN --mount=type=cache,target=/root/.cache/pip pip install -r /requirements.txt
5150

5251
# this resolves permissions issues in local env
@@ -69,7 +68,7 @@ CMD ["ttyd", "-W", "bash"]
6968

7069
FROM app AS tests
7170
USER root
72-
COPY --from=poetry /requirements-dev.txt /requirements-dev.txt
71+
COPY --from=uv /requirements-dev.txt /requirements-dev.txt
7372
RUN --mount=type=cache,target=/root/.cache/pip pip install -r /requirements-dev.txt
7473
COPY pyproject.toml tests.py ./
7574

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ You can secure `ttyd` by:
214214
## Development
215215
216216
```bash
217-
# 1. install poetry
218-
poetry install
217+
# 1. install uv (see https://docs.astral.sh/uv/)
218+
uv sync
219219
# 2. hack
220-
# 3. lint directly or install pre-commit hooks with poetry run pre-commit install
221-
poetry run pre-commit run -a
220+
# 3. lint directly or install pre-commit hooks with uv run pre-commit install
221+
uv run pre-commit run -a
222222
# 4. run tests
223-
poetry run pytest
223+
uv run pytest
224224
```
225225
226226
---

poetry.lock

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

pyproject.toml

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
[tool.poetry]
1+
[project]
22
authors = []
3+
dependencies = [
4+
"argcomplete>=3.6.2,<4",
5+
"fake-useragent>=2.2.0,<3",
6+
"filelock>=3.18.0",
7+
"lxml>=6.0.2",
8+
"notifiers>=1.3.6",
9+
"python-dotenv>=1.1.1",
10+
"requests>=2.32.4",
11+
"rich>=14.0.0",
12+
"selenium-stealth>=1.0.6",
13+
"selenium>=4.34.0",
14+
"tenacity>=9.1.2",
15+
"xmpppy>=0.7.1",
16+
]
317
description = "medihunter fork"
4-
license = "GNU GPLv3"
18+
license = "GPL-3.0-or-later"
519
name = "medichaser"
620
readme = "README.md"
21+
requires-python = ">=3.13,<3.14"
722
version = "0.5.0"
823

24+
[project.scripts]
25+
medichaser = "medichaser:medichaser"
26+
27+
[dependency-groups]
28+
dev = [
29+
"mypy>=1.16.1,<2",
30+
"pytest-cov>=6.2.1,<7",
31+
"pytest-xdist>=3.8.0,<4",
32+
"pytest>=8.4.1,<9",
33+
"ruff>=0.12.1",
34+
"types-requests>=2.32.0.20240712,<3",
35+
]
36+
937
[tool.ruff]
1038
target-version = "py313"
1139

40+
[build-system]
41+
build-backend = "hatchling.build"
42+
requires = ["hatchling"]
43+
1244
[tool.ruff.lint]
1345
# pycodestyle, pyflakes, isort, pylint, pyupgrade
1446
ignore = ["E501", "PLR0915", "PLR2004"]
@@ -18,32 +50,6 @@ select = ["E", "F", "I", "PL", "UP", "W"]
1850
max-args = 12
1951
max-branches = 20
2052

21-
[tool.poetry.dependencies]
22-
argcomplete = "^3.6.2"
23-
fake-useragent = "^2.2.0"
24-
filelock = ">=3.18.0"
25-
lxml = ">=6.0.0"
26-
notifiers = ">=1.3.6"
27-
python = ">=3.13"
28-
python-dotenv = ">=1.1.1"
29-
requests = ">=2.32.4"
30-
rich = ">=14.0.0"
31-
selenium = ">=4.34.0"
32-
selenium-stealth = ">=1.0.6"
33-
tenacity = ">=9.1.2"
34-
xmpppy = ">=0.7.1"
35-
36-
[tool.poetry.scripts]
37-
medichaser = "medichaser:medichaser"
38-
39-
[tool.poetry.group.dev.dependencies]
40-
mypy = "^1.16.1"
41-
pytest = "^8.4.1"
42-
pytest-cov = "^6.2.1"
43-
pytest-xdist = "^3.8.0"
44-
ruff = ">=0.12.1"
45-
types-requests = "^2.32.0.20240712"
46-
4753
[tool.mypy]
4854
ignore_missing_imports = true
4955
python_version = "3.13"
@@ -56,7 +62,3 @@ source = ["."]
5662
[tool.pytest.ini_options]
5763
addopts = "-vv -n auto --cov --cov-report xml --cov-report term-missing --cov-fail-under=80"
5864
testpaths = ["tests.py"]
59-
60-
[build-system]
61-
build-backend = "poetry.core.masonry.api"
62-
requires = ["poetry-core>=1.0.0"]

0 commit comments

Comments
 (0)