From 5deac05cdca5b7277f5dadc48dedcd14c86f1df5 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 20 Jan 2025 19:58:02 +0100 Subject: [PATCH] use uv --- .github/workflows/daily.yaml | 15 +++++++-------- Dockerfile | 4 +--- Makefile | 2 +- README.md | 2 +- requirements.txt | 3 --- scripts/jinja.py | 7 +++++++ scripts/update/discogs.py | 6 ++++++ scripts/update/hledger.py | 6 ++++++ scripts/update/letterboxd.py | 6 ++++++ 9 files changed, 35 insertions(+), 16 deletions(-) delete mode 100644 requirements.txt diff --git a/.github/workflows/daily.yaml b/.github/workflows/daily.yaml index e4b4c776..c7c2b0b4 100644 --- a/.github/workflows/daily.yaml +++ b/.github/workflows/daily.yaml @@ -12,19 +12,18 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 with: - cache: "pip" - - run: python3 -m venv venv - - run: source venv/bin/activate - - run: python3 -m pip install -r requirements.txt + enable-cache: true + cache-suffix: "optional-suffix" - - run: python3 ./scripts/update/letterboxd.py + - run: uv run ./scripts/update/letterboxd.py - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Update movies - - run: python3 ./scripts/update/discogs.py --token "${{ secrets.DISCOGS_API_KEY }}" + - run: uv run ./scripts/update/discogs.py --token "${{ secrets.DISCOGS_API_KEY }}" - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Update records @@ -38,7 +37,7 @@ jobs: ref: "master" - name: Setup hledger uses: ngalaiko/setup-hledger@v1 - - run: python3 ./scripts/update/hledger.py --file "$GITHUB_WORKSPACE/ledger/main.ledger" + - run: uv run ./scripts/update/hledger.py --file "$GITHUB_WORKSPACE/ledger/main.ledger" - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Update Restaurants and Cafes diff --git a/Dockerfile b/Dockerfile index b239d317..a78ea792 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-alpine3.20 as build +FROM ghcr.io/astral-sh/uv:python3.13-alpine as build WORKDIR /app RUN apk add --update --no-cache \ imagemagick imagemagick-dev libjpeg-turbo-dev libpng-dev libwebp-dev \ @@ -6,8 +6,6 @@ RUN apk add --update --no-cache \ make \ jq \ yq -COPY requirements.txt requirements.txt -RUN pip install --break-system-packages -r requirements.txt RUN wget --quiet "https://github.com/cooklang/cookcli/releases/download/v0.8.0/cook-x86_64-unknown-linux-musl.tar.gz" \ && echo "4e1b95202d92b492027a5df2f78624679f93f368a9b5832e2ec94f518890f130 cook-x86_64-unknown-linux-musl.tar.gz" | sha256sum -c \ && tar -xzf "cook-x86_64-unknown-linux-musl.tar.gz" -C /usr/bin diff --git a/Makefile b/Makefile index f7c211b5..ef7b5c61 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PANDOC_BIN := pandoc IMAGEMAGICK_BIN := magick JQ_BIN := jq YQ_BIN := yq -J2_BIN := python3 ./scripts/jinja.py +J2_BIN := uv run -s ./scripts/jinja.py COOK_BIN := cook # Find input files diff --git a/README.md b/README.md index 4d172c6a..519bce70 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ my website ## requirements -- [python3](https://www.python.org) +- [uv](https://docs.astral.sh/uv) - [bash](https://www.gnu.org/software/bash/) - [make](https://www.gnu.org/software/make/) - [sed](https://www.gnu.org/software/sed/) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9f4eeafc..00000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Jinja2==3.1.4 -python-slugify==8.0.4 -beautifulsoup4==4.11.1 diff --git a/scripts/jinja.py b/scripts/jinja.py index 97d843b7..70561117 100644 --- a/scripts/jinja.py +++ b/scripts/jinja.py @@ -1,3 +1,10 @@ +# /// script +# requires-python = ">=3.13" +# dependencies = [ +# "jinja2", +# "python-slugify", +# ] +# /// import sys import json import jinja2 diff --git a/scripts/update/discogs.py b/scripts/update/discogs.py index 0ed02598..259c2d77 100755 --- a/scripts/update/discogs.py +++ b/scripts/update/discogs.py @@ -1,3 +1,9 @@ +# /// script +# requires-python = ">=3.13" +# dependencies = [ +# "python-slugify", +# ] +# /// import os import time import argparse diff --git a/scripts/update/hledger.py b/scripts/update/hledger.py index 484ce11f..b4446cc3 100755 --- a/scripts/update/hledger.py +++ b/scripts/update/hledger.py @@ -1,3 +1,9 @@ +# /// script +# requires-python = ">=3.13" +# dependencies = [ +# "python-slugify", +# ] +# /// import csv from slugify import slugify import subprocess diff --git a/scripts/update/letterboxd.py b/scripts/update/letterboxd.py index 85f9b0e2..1f6b711c 100755 --- a/scripts/update/letterboxd.py +++ b/scripts/update/letterboxd.py @@ -1,3 +1,9 @@ +# /// script +# requires-python = ">=3.13" +# dependencies = [ +# "beautifulsoup4", +# ] +# /// from bs4 import BeautifulSoup import argparse import json