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

feat: switch to uv package manager #30

Merged
merged 1 commit into from
Sep 17, 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
7 changes: 3 additions & 4 deletions .github/workflows/lint-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache
key: self-runner-${{ runner.os }}-python-3.12-poetry-${{ hashFiles('poetry.lock') }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
key: self-runner-${{ runner.os }}-python-3.12-${{ hashFiles('uv.lock') }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install
pip install uv
uv sync --frozen
- name: pre-commit lint
run: make lint
- name: pytest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
rev: v0.6.5
hooks:
- id: ruff
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
##### Base Stage #####
FROM python:3.12-slim-bookworm as base
FROM python:3.12-slim-bookworm AS base

# Set default path
ENV PATH="/app/.venv/bin:${PATH}"

##### Builder Stage #####
FROM base as builder
FROM base AS builder

# Set default workdir
WORKDIR /app

# Create virtualenv and install Python packages
RUN pip install --no-cache-dir pip -U && \
pip install --no-cache-dir poetry && \
poetry config virtualenvs.in-project true
COPY ./poetry.lock poetry.lock
pip install --no-cache-dir uv
COPY ./uv.lock uv.lock
COPY ./pyproject.toml pyproject.toml
RUN poetry install --only main
RUN uv sync --no-dev --frozen

# Copy app files to workdir
COPY secure_qrcode ./secure_qrcode
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.PHONY: test
test:
poetry run pytest -v
uv run pytest -v

.PHONY: lint
lint:
poetry run pre-commit run --all-files
uv run pre-commit run --all-files

.PHONY: run-api
run-api:
poetry run uvicorn secure_qrcode.api:app --reload
uv run uvicorn secure_qrcode.api:app --reload

.PHONY: docker-build
docker-build:
Expand Down
1,530 changes: 0 additions & 1,530 deletions poetry.lock

This file was deleted.

37 changes: 17 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
[tool.poetry]
[project]
name = "secure-qrcode"
version = "0.1.0"
description = "Encrypt your data using the modern ChaCha20-Poly1305 cipher and export it into a secure QR code"
authors = ["Allisson Azevedo"]
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"fastapi>=0.114.2",
"jinja2>=3.1.4",
"pycryptodome>=3.20.0",
"pydantic-settings>=2.5.2",
"qrcode[pil]>=7.4.2",
"uvicorn[standard]>=0.30.6",
]

[tool.poetry.dependencies]
python = "^3.12"
qrcode = {extras = ["pil"], version = "^7.4.2"}
pycryptodome = "^3.20.0"
fastapi = "^0.111.0"
uvicorn = {extras = ["standard"], version = "^0.30.1"}
pydantic-settings = "^2.3.4"
jinja2 = "^3.1.4"

[tool.poetry.group.test.dependencies]
pytest = "^8.2.2"
pre-commit = "^3.7.1"
pytest-cov = "^5.0.0"
httpx = "^0.27.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
dev-dependencies = [
"httpx>=0.27.2",
"pre-commit>=3.8.0",
"pytest-cov>=5.0.0",
"pytest>=8.3.3",
]

[tool.pytest.ini_options]
minversion = "8.2"
Expand Down
690 changes: 690 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

Loading