Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Switch from Poetry to uv #152

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
lint:
uses: BlindfoldedSurgery/actions-python/.github/workflows/lint.yml@v2
with:
build-tool: uv
python-version: '3.13'

test:
uses: BlindfoldedSurgery/actions-python/.github/workflows/test.yml@v2
with:
build-tool: uv
python-version: '3.13'

build-container-image:
Expand Down
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tools]
python = "3.13"
uv = "0.5"

[env]
_.python.venv = { path = '.venv', create = true }
21 changes: 16 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
FROM ghcr.io/blindfoldedsurgery/poetry:2.1.2-pipx-3.13-bookworm
FROM ghcr.io/astral-sh/uv:0.5-python3.13-bookworm-slim

COPY [ "poetry.toml", "poetry.lock", "pyproject.toml", "./" ]
RUN apt-get update -qq \
&& apt-get install -yq --no-install-recommends tini \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

RUN poetry install --no-interaction --ansi --only=main --no-root
RUN groupadd --system --gid 500 app
RUN useradd --system --uid 500 --gid app --create-home --home-dir /app app

USER app
WORKDIR /app

COPY [ "uv.lock", "pyproject.toml", "./" ]

RUN uv sync --locked --no-install-workspace --all-extras --no-dev

# We don't want the tests
COPY src/app ./src/app

RUN poetry install --no-interaction --ansi --only-root
RUN uv sync --locked --no-editable --all-extras --no-dev

ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION

ENTRYPOINT [ "tini", "--", "poetry", "run", "python", "-m", "app" ]
ENV UV_NO_SYNC=true
ENTRYPOINT [ "tini", "--", "uv", "run", "-m", "app" ]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023
Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ check: lint test

.PHONY: lint
lint:
poetry run ruff format src/
poetry run ruff check --fix --show-fixes src/
poetry run mypy src/
uv run ruff format src/
uv run ruff check --fix --show-fixes src/
uv run mypy src/

.PHONY: test
test:
poetry run pytest src/
uv run pytest src/
433 changes: 0 additions & 433 deletions poetry.lock

This file was deleted.

2 changes: 0 additions & 2 deletions poetry.toml

This file was deleted.

51 changes: 25 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
[project]
requires-python = "==3.13.*"

[tool.poetry]
name = "location-bot"
name = "app"
description = ""
version = "1.0.0"
authors = ["BlindfoldedSurgery <[email protected]>"]
license = "MIT"
packages = [
{ include = "app", from = "src" }
authors = [{ name = "BlindfoldedSurgery", email = "[email protected]" }]
classifiers = [
"Private :: Do Not Upload",
"License :: OSI Approved :: MIT License",
]

dependencies = [
"bs-config [dotenv] ==1.1.1",
"python-telegram-bot ==21.9",
"sentry-sdk >=2.0.0, <3.0.0",
]

[[tool.poetry.source]]
[dependency-groups]
dev = [
"mypy ==1.13.*",
"pytest >=8.0.0, <9.0.0",
"ruff ==0.8.3",
"types-requests >=2.28.11, <3.0.0",
]

[[tool.uv.index]]
name = "internal"
url = "https://pypi.bjoernpetersen.net"
priority = "explicit"

[tool.poetry.dependencies]
bs-config = { version = "1.1.1", extras = ["dotenv"], source = "internal" }
certifi = "2024.8.30"
python = "~3.13"
python-telegram-bot = "21.9"
sentry-sdk = "^2.0.0"
explicit = true

[tool.poetry.group.dev.dependencies]
mypy = "~1.13"
pytest = "^8.0.0"
ruff = "0.8.3"
types-requests = "^2.28.11"
[tool.uv.sources]
bs-config = { index = "internal" }

[build-system]
requires = ["poetry-core>=1.3.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.mypy]
strict = true
Expand Down Expand Up @@ -61,6 +63,3 @@ ignore = [
# redundant-open-modes
"UP015",
]

[tool.ruff.lint.isort]
known-first-party = ["app"]
293 changes: 293 additions & 0 deletions uv.lock

Large diffs are not rendered by default.