From 6299d2ca232741e7e33e7fd8a5a10059bd743da7 Mon Sep 17 00:00:00 2001 From: Calum Young <32770960+calumy@users.noreply.github.com> Date: Mon, 30 Dec 2024 15:48:39 +0000 Subject: [PATCH] Update mirror.py to a uv script (#110) ## Summary From my reading of the [UV docs](https://docs.astral.sh/uv/guides/scripts/), `mirror.py` would be a good example of a standalone script. This PR updates `mirror.py` and the `main.yml` workflow to be a UV script and makes use of UV in the update process. ## Test Plan - Update the uv version (currently 0.8.4) to an older version e.g. 0.8.3 in both `pyproject.toml` and `README.md` - Run `uv run --no-project mirror.py` to check the update process still works as expected --- .github/workflows/main.yml | 12 +++--------- mirror.py | 9 +++++++++ pyproject.toml | 6 ------ requirements-dev.txt | 11 ----------- 4 files changed, 12 insertions(+), 26 deletions(-) delete mode 100644 requirements-dev.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cfc9a44..5925bd8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,21 +16,15 @@ jobs: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: download uv - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - - run: uv pip install --system -r requirements-dev.txt + - name: Install uv + uses: astral-sh/setup-uv@v5 - name: set git config run: | git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - run: python mirror.py + - run: uv run --no-project mirror.py - name: check for unpushed commits id: check_unpushed diff --git a/mirror.py b/mirror.py index 7a8bbe8..a1df4cd 100644 --- a/mirror.py +++ b/mirror.py @@ -1,3 +1,12 @@ +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "packaging==23.1", +# "urllib3==2.0.5", +# ] +# /// +"""Update ruff-pre-commit to the latest version of ruff.""" + import re import subprocess import tomllib diff --git a/pyproject.toml b/pyproject.toml index 6a43f1c..7dfb90f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,3 @@ version = "0.0.0" dependencies = [ "ruff==0.8.4", ] - -[project.optional-dependencies] -dev = [ - "packaging~=23.1", - "urllib3>=2.0.5,<3.0.0", -] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index c98d526..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,11 +0,0 @@ -# This file was autogenerated by uv via the following command: -# uv pip compile --extra=dev --generate-hashes -o requirements-dev.txt --no-emit-package=ruff pyproject.toml -packaging==23.1 \ - --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ - --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f -urllib3==2.0.5 \ - --hash=sha256:13abf37382ea2ce6fb744d4dad67838eec857c9f4f57009891805e0b5e123594 \ - --hash=sha256:ef16afa8ba34a1f989db38e1dbbe0c302e4289a47856990d0682e374563ce35e - -# The following packages were excluded from the output: -# ruff