Skip to content

Commit

Permalink
chore: Migrate from Poetry to uv, bump dependencies and python version.
Browse files Browse the repository at this point in the history
  • Loading branch information
elisiariocouto committed Jan 13, 2025
1 parent 6b2cb8a commit 33006f8
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 611 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version-file: "pyproject.toml"

- name: Build Package
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry build -f wheel
run: uv build

- name: Publish package
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish
run: uv publish

push-docker:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.6.5"
rev: "v0.9.1"
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: ".*\\.md$"
Expand Down
31 changes: 18 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
FROM python:3.12-alpine as builder
ARG POETRY_VERSION="1.7.1"
FROM python:3.13-alpine AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /app
RUN apk add --no-cache gcc libffi-dev musl-dev && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -q poetry=="${POETRY_VERSION}"
COPY . .
RUN poetry config virtualenvs.create false && poetry build -f wheel

FROM python:3.12-alpine
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-editable

COPY . /app

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable

FROM python:3.13-alpine

LABEL org.opencontainers.image.source="https://github.com/elisiariocouto/leggen"
LABEL org.opencontainers.image.authors="Elisiário Couto <elisiario@couto.io>"
Expand All @@ -17,8 +22,8 @@ LABEL org.opencontainers.image.title="leggen"
LABEL org.opencontainers.image.description="An Open Banking CLI"
LABEL org.opencontainers.image.url="https://github.com/elisiariocouto/leggen"

WORKDIR /app
COPY --from=builder /app/dist/ /app/
RUN pip --no-cache-dir install leggen*.whl && \
rm leggen*.whl
ENTRYPOINT ["/usr/local/bin/leggen"]
# Copy the environment, but not the source code
COPY --from=builder --chown=app:app /app/.venv /app/.venv

# Run the application
ENTRYPOINT ["/app/.venv/bin/leggen"]
554 changes: 0 additions & 554 deletions poetry.lock

This file was deleted.

62 changes: 35 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
[tool.poetry]
[project]
name = "leggen"
version = "0.6.7"
description = "An Open Banking CLI"
authors = ["Elisiário Couto <elisiario@couto.io>"]
authors = [{ name = "Elisiário Couto", email = "elisiario@couto.io" }]
requires-python = "~=3.12"
readme = "README.md"
license = "MIT"
repository = "https://github.com/elisiariocouto/leggen"
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Financial and Insurance Industry",
"Topic :: Utilities",
"Topic :: Office/Business :: Financial",
]
keywords = [
"openbanking",
"cli",
Expand All @@ -24,28 +16,44 @@ keywords = [
"transactions",
"finance",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Financial and Insurance Industry",
"Topic :: Utilities",
"Topic :: Office/Business :: Financial",
]
dependencies = [
"click>=8.1.7,<9",
"requests>=2.31.0,<3",
"loguru>=0.7.2,<0.8",
"tabulate>=0.9.0,<0.10",
"pymongo>=4.6.1,<5",
"discord-webhook>=1.3.1,<2",
]

packages = [{ "include" = "leggen" }]
[project.urls]
Repository = "https://github.com/elisiariocouto/leggen"

[tool.poetry.dependencies]
python = "^3.12"
click = "^8.1.7"
requests = "^2.31.0"
loguru = "^0.7.2"
tabulate = "^0.9.0"
pymongo = "^4.6.1"
discord-webhook = "^1.3.1"
[project.scripts]
leggen = "leggen.main:cli"

[tool.poetry.group.dev.dependencies]
ruff = "^0.6.1"
pre-commit = "^3.6.0"
[dependency-groups]
dev = [
"ruff>=0.6.1",
"pre-commit>=3.6.0",
]

[tool.poetry.scripts]
leggen = "leggen.main:cli"
[tool.hatch.build.targets.sdist]
include = ["leggen"]

[tool.hatch.build.targets.wheel]
include = ["leggen"]

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

[tool.ruff]
lint.ignore = ["E501", "B008", "B006"]
Expand Down
8 changes: 4 additions & 4 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ function check_command {

check_command git
check_command git-cliff
check_command poetry
check_command uv

if [ -z "$1" ]; then
echo " > No semver verb specified, run release with <major|minor|patch> parameter."
exit 1
fi

CURRENT_VERSION=$(poetry version -s)
CURRENT_VERSION=$(uvx poetry version -s)
echo " > Current version is $CURRENT_VERSION"

poetry version "$1"
NEXT_VERSION=$(poetry version -s)
poetry uvx version "$1"
NEXT_VERSION=$(uvx poetry version -s)

echo " > leggen bumped to $NEXT_VERSION"
echo "Updating CHANGELOG.md"
Expand Down
Loading

0 comments on commit 33006f8

Please sign in to comment.