From 09248de32f5d4734356aa2034f667441d8388505 Mon Sep 17 00:00:00 2001 From: utensil Date: Mon, 28 Oct 2024 15:25:59 +0800 Subject: [PATCH] Start using uv for python setup --- .github/workflows/gh-pages.yml | 6 +++--- fize.py | 7 +++++-- justfile | 16 ++++++++++++++++ split_bib.py | 7 +++++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 6282a5c..b50dcea 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -70,10 +70,10 @@ jobs: sudo apt-get install libev-dev opam pin add forester git+https://git.sr.ht/~jonsterling/ocaml-forester#56de06afe952d752c1a13fdcd8bb56c5fef9956f --yes opam install forester --yes - - name: Install Python - uses: actions/setup-python@v5 + - name: Setup Python via uv + uses: astral-sh/setup-uv@v3 with: - python-version: "3.11" + enable-cache: true - name: Install Homebrew run: | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" diff --git a/fize.py b/fize.py index 18ec64b..dd908a4 100755 --- a/fize.py +++ b/fize.py @@ -1,5 +1,8 @@ -#!/usr/bin/env python3 - +#!/usr/bin/env -S uv run +# /// script +# requires-python = ">=3.11,<3.12" +# dependencies = [] +# /// import sys import re diff --git a/justfile b/justfile index 7976443..4aee4a7 100644 --- a/justfile +++ b/justfile @@ -173,5 +173,21 @@ lazyvim PROJ="forest": sync-lazyvim #!/usr/bin/env bash cd ~/projects/{{PROJ}} && nvim --cmd 'set runtimepath+=~/.config/lazyvim/' -u ~/.config/lazyvim/lazyvim-init.lua . +# https://github.com/astral-sh/uv + +[unix] +prep-uv: + curl -LsSf https://astral.sh/uv/install.sh | sh + + +[windows] +prep-uv: + powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" + +prep-py: + uv python install 3.11 + uv venv --python 3.11 + + # act: # ./act.sh diff --git a/split_bib.py b/split_bib.py index f6ba0ef..11c26c7 100755 --- a/split_bib.py +++ b/split_bib.py @@ -1,4 +1,8 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run +# /// script +# requires-python = ">=3.11,<3.12" +# dependencies = ["bibtexparser"] +# /// import json import os import pathlib @@ -6,7 +10,6 @@ import subprocess import sys from pathlib import Path -# pip install bibtexparser import bibtexparser from bibtexparser.bwriter import BibTexWriter, SortingStrategy import re