Skip to content

Commit 80e25ba

Browse files
authored
Merge pull request #67 from guerda/build_uv
draft: build: migrate to uv
2 parents aeb2b1b + c38b94f commit 80e25ba

10 files changed

Lines changed: 990 additions & 920 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
- name: Install dependencies
2727
run: |
2828
python -m pip install --upgrade pip
29-
pip install pipenv
30-
if [ -f Pipfile.lock ]; then pipenv install --dev; fi
29+
pip install uv
30+
uv sync
3131
- name: Lint with ruff
3232
run: |
33-
pipenv run ruff check . --statistics
33+
uv run ruff check . --statistics
3434
- name: Test with pytest
3535
run: |
36-
pipenv run pytest
36+
uv run pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
musiclibrary.db
22
.DS_Store
3+
__pycache__

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
FROM python:3.11
1+
FROM python:3.11-slim
2+
# Install uv.
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
4+
25
WORKDIR /app
3-
COPY ./Pipfile* /app/
4-
RUN pip install pipenv
5-
RUN pipenv sync
6+
COPY ./uv.lock ./pyproject.toml /app/
7+
RUN uv sync --frozen --no-cache
68
COPY templates /app/templates/
79
COPY static /app/static/
810
COPY beetsstatistics.py app.py /app
9-
CMD ["pipenv", "run", "prod"]
11+
CMD ["/app/.venv/bin/fastapi", "run", "app.py"]

Pipfile

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

Pipfile.lock

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

app.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
from fastapi import FastAPI, Request
2-
from fastapi.templating import Jinja2Templates
3-
from fastapi.staticfiles import StaticFiles
4-
from fastapi.responses import FileResponse, HTMLResponse
5-
from beetsstatistics import AlbumSort, BeetsStatistics, DBNotFoundError, DBQueryError
6-
import humanize
7-
from fastapi import Depends
8-
from typing import Annotated
9-
from pydantic_settings import BaseSettings
10-
from fastapi import HTTPException
111
import logging
2+
from typing import Annotated
123
from urllib.parse import quote_plus
134

5+
import humanize
6+
from fastapi import Depends, FastAPI, HTTPException, Request
7+
from fastapi.responses import FileResponse, HTMLResponse
8+
from fastapi.staticfiles import StaticFiles
9+
from fastapi.templating import Jinja2Templates
10+
from pydantic_settings import BaseSettings
11+
12+
from beetsstatistics import AlbumSort, BeetsStatistics, DBNotFoundError, DBQueryError
13+
1414
logger = logging.getLogger("uvicorn.error")
1515

1616

@@ -47,7 +47,8 @@ async def get_beets_statistics():
4747
app.mount("/static", StaticFiles(directory="static"), name="static")
4848

4949
templates = Jinja2Templates(directory="templates")
50-
templates.env.filters['quote_plus'] = lambda u: quote_plus(u)
50+
templates.env.filters["quote_plus"] = lambda u: quote_plus(u)
51+
5152

5253
@app.get("/", response_class=HTMLResponse)
5354
async def get_general_stats(

beetsstatistics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import sqlite3
2-
import yaml
3-
import os
41
import argparse
2+
import os
53
import os.path
4+
import sqlite3
65
from enum import Enum
76

7+
import yaml
8+
89
LOSSY_FORMATS = ["mp3", "aac", "ogg"]
910
LOSSLESS_FORMATS = ["flac", "wav"]
1011

pyproject.toml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1+
[project]
2+
name = ""
3+
version = "0.0.1"
4+
requires-python = "~=3.11"
5+
dependencies = [
6+
"fastapi[standard]",
7+
"pyyaml",
8+
"jinja2",
9+
"humanize",
10+
"pydantic",
11+
"pydantic-settings",
12+
]
13+
114
[tool.pytest.ini_options]
215
pythonpath = [
316
"."
4-
]
17+
]
18+
19+
[dependency-groups]
20+
dev = [
21+
"ruff",
22+
"pytest",
23+
]
24+
25+
[tool.uv]
26+
package = false
27+
28+
[[tool.uv.index]]
29+
name = "pypi"
30+
url = "https://pypi.org/simple"
31+
32+
[tool.ruff.lint]
33+
select = ["I"]

test/beetsstatistics_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
from beetsstatistics import BeetsStatistics
34

45

uv.lock

Lines changed: 931 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)