Skip to content

Commit 730482d

Browse files
authored
use uv (#496)
2 parents 5f29807 + f38ca06 commit 730482d

File tree

24 files changed

+1465
-447
lines changed

24 files changed

+1465
-447
lines changed

.devcontainer/on-create-command.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
#!/bin/bash
22
set -e
3-
python3 -m venv --upgrade-deps .venv
4-
. .venv/bin/activate
5-
pip install -r requirements/dev.txt
6-
pip install -e .
3+
4+
# Install uv if not already installed
5+
if ! command -v uv &> /dev/null; then
6+
echo "Installing uv..."
7+
curl -LsSf https://astral.sh/uv/install.sh | sh
8+
export PATH="$HOME/.cargo/bin:$PATH"
9+
fi
10+
11+
# Create venv using uv and install dependencies
12+
echo "Creating virtual environment and installing dependencies..."
13+
uv sync
14+
15+
# Install pre-commit hooks
16+
echo "Installing pre-commit hooks..."
717
pre-commit install --install-hooks

.github/workflows/lock.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
permissions:
1111
issues: write
1212
pull-requests: write
13+
discussions: write
1314
concurrency:
1415
group: lock
1516
jobs:

.github/workflows/pre-commit.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ jobs:
77
main:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
11-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
12-
with:
13-
python-version: 3.x
14-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
15-
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
16-
if: ${{ !cancelled() }}
10+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
11+
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
12+
with:
13+
enable-cache: true
14+
prune-cache: false
15+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
16+
id: setup-python
17+
with:
18+
python-version-file: pyproject.toml
19+
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
20+
with:
21+
path: ~/.cache/pre-commit
22+
key: pre-commit|${{ hashFiles('pyproject.toml', '.pre-commit-config.yaml') }}
23+
- run: uv run --locked --group pre-commit pre-commit run --show-diff-on-failure --color=always --all-files
24+
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
25+
if: ${{ !cancelled() }}

.github/workflows/publish.yaml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Publish
22
on:
33
push:
4-
tags:
5-
- '*'
4+
tags: ['*']
65
# When a new version of Python is released, the workflow can be run manually to
76
# publish new wheels for the existing tag.
87
workflow_dispatch:
@@ -16,20 +15,22 @@ on:
1615
jobs:
1716
sdist:
1817
runs-on: ubuntu-latest
18+
outputs:
19+
hash: ${{ steps.hash.outputs.hash }}
1920
steps:
2021
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2122
with:
2223
ref: ${{ inputs.tag }}
23-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
24+
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
2425
with:
25-
python-version: '3.x'
26-
cache: pip
27-
cache-dependency-path: requirements/*.txt
28-
- run: pip install -r requirements/build.txt
29-
# Use the commit date instead of the current date during the build.
26+
enable-cache: true
27+
prune-cache: false
28+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
29+
with:
30+
python-version-file: pyproject.toml
3031
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
31-
- run: python -m build --sdist
32-
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
32+
- run: uv build --sdist
33+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
3334
with:
3435
name: build-sdist
3536
path: ./dist
@@ -45,22 +46,26 @@ jobs:
4546
os: [ubuntu-latest, windows-latest, macos-latest]
4647
steps:
4748
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48-
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
49+
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
50+
with:
51+
enable-cache: true
52+
prune-cache: false
4953
- name: Set up QEMU
5054
if: runner.os == 'Linux'
51-
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
55+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
5256
with:
5357
platforms: arm64
54-
- uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3
58+
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
59+
- uses: pypa/cibuildwheel@faf86a6ed7efa889faf6996aa23820831055001a # v2.23.3
5560
env:
5661
# For workflow_dispatch, only build the new Python version.
5762
CIBW_BUILD: ${{ inputs.python && format('{0}-*', inputs.python) || null }}
5863
CIBW_SKIP: pp*
5964
CIBW_ARCHS_LINUX: auto aarch64
6065
CIBW_ARCHS_MACOS: auto universal2
61-
CIBW_BUILD_FRONTEND: build
62-
CIBW_FREE_THREADED_SUPPORT: 1
63-
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
66+
CIBW_ENABLE: cpython-freethreading
67+
CIBW_BUILD_FRONTEND: build[uv]
68+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
6469
with:
6570
name: build-wheels-${{ matrix.os }}
6671
path: ./wheelhouse
@@ -71,7 +76,7 @@ jobs:
7176
outputs:
7277
hash: ${{ steps.hash.outputs.hash }}
7378
steps:
74-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
79+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
7580
with:
7681
path: dist
7782
pattern: build-*
@@ -86,7 +91,7 @@ jobs:
8691
id-token: write
8792
contents: write
8893
# Can't pin with hash due to how this workflow works.
89-
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
94+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0
9095
with:
9196
base64-subjects: ${{ needs.hash.outputs.hash }}
9297
# When building more wheels, use the Python version as the provenance file name.
@@ -99,12 +104,12 @@ jobs:
99104
permissions:
100105
contents: write
101106
steps:
102-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
107+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
103108
with:
104109
path: dist
105110
pattern: build-*
106111
merge-multiple: true
107-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
112+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
108113
with:
109114
pattern: '*.intoto.jsonl'
110115
# When building a new tag, create a new draft release.
@@ -136,15 +141,11 @@ jobs:
136141
permissions:
137142
id-token: write
138143
steps:
139-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
144+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
140145
with:
141146
path: dist
142147
pattern: build-*
143148
merge-multiple: true
144-
- uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3
145-
with:
146-
repository-url: https://test.pypi.org/legacy/
147-
skip-existing: true
148-
- uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3
149+
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
149150
with:
150151
skip-existing: true

.github/workflows/tests.yaml

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Tests
22
on:
3+
pull_request:
4+
paths-ignore: ['docs/**', 'README.md']
35
push:
46
branches: [main, stable]
5-
paths-ignore: ['docs/**', '*.md', '*.rst']
6-
pull_request:
7-
paths-ignore: ['docs/**', '*.md', '*.rst']
7+
paths-ignore: ['docs/**', 'README.md']
88
jobs:
99
tests:
1010
name: ${{ matrix.name || matrix.python }}
@@ -14,45 +14,39 @@ jobs:
1414
matrix:
1515
include:
1616
- {python: '3.13'}
17-
- {name: 'Free-threaded', python: '3.13', free-threaded: true}
17+
- {python: '3.13t'}
18+
- {name: Windows, python: '3.13', os: windows-latest}
19+
- {name: Mac, python: '3.13', os: macos-latest}
1820
- {python: '3.12'}
19-
- {name: Windows, python: '3.12', os: windows-latest}
20-
- {name: Mac, python: '3.12', os: macos-latest}
2121
- {python: '3.11'}
2222
- {python: '3.10'}
2323
- {python: '3.9'}
24-
- {name: PyPy, python: 'pypy-3.10', tox: pypy310}
24+
- {name: PyPy, python: 'pypy-3.11', tox: pypy311}
2525
steps:
2626
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
28-
if: ${{ !matrix.free-threaded }}
27+
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
2928
with:
30-
python-version: ${{ matrix.python }}
31-
allow-prereleases: true
32-
cache: pip
33-
cache-dependency-path: requirements*/*.txt
34-
- uses: deadsnakes/action@e640ac8743173a67cca4d7d77cd837e514bf98e8 # v3.2.0
35-
if: ${{ matrix.free-threaded }}
29+
enable-cache: true
30+
prune-cache: false
31+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3632
with:
3733
python-version: ${{ matrix.python }}
38-
nogil: true
39-
- run: pip install tox
40-
- env:
41-
PYTHON_GIL: ${{ matrix.free-threaded && '0' || '1' }}
42-
run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}
34+
allow-prereleases: true
35+
- run: uv run --locked tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}
4336
typing:
4437
runs-on: ubuntu-latest
4538
steps:
4639
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47-
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
40+
- uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
41+
with:
42+
enable-cache: true
43+
prune-cache: false
44+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
4845
with:
49-
python-version: '3.x'
50-
cache: pip
51-
cache-dependency-path: requirements*/*.txt
46+
python-version-file: pyproject.toml
5247
- name: cache mypy
53-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
48+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
5449
with:
5550
path: ./.mypy_cache
5651
key: mypy|${{ hashFiles('pyproject.toml') }}
57-
- run: pip install tox
58-
- run: tox run -e typing
52+
- run: uv run --locked tox run -e typing

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
.idea/
22
.vscode/
3-
.venv*/
4-
venv*/
53
__pycache__/
64
*.egg-info/
75
*.so

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.7.1
3+
rev: 76e47323a83cd9795e4ff9a1de1c0d2eef610f17 # frozen: v0.11.11
44
hooks:
55
- id: ruff
66
- id: ruff-format
7+
- repo: https://github.com/astral-sh/uv-pre-commit
8+
rev: 648bdbfd6bb1a82f132ecc2c666e0d1b2e4b0d94 # frozen: 0.7.8
9+
hooks:
10+
- id: uv-lock
711
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v5.0.0
12+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
913
hooks:
1014
- id: check-merge-conflict
1115
- id: debug-statements

.readthedocs.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ version: 2
22
build:
33
os: ubuntu-24.04
44
tools:
5-
python: '3.12'
6-
python:
7-
install:
8-
- requirements: requirements/docs.txt
9-
- method: pip
10-
path: .
11-
sphinx:
12-
builder: dirhtml
13-
fail_on_warning: true
5+
python: '3.13'
6+
commands:
7+
- asdf plugin add uv
8+
- asdf install uv latest
9+
- asdf global uv latest
10+
- uv run --group docs sphinx-build -W -b dirhtml docs $READTHEDOCS_OUTPUT/html

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include CHANGES.rst
2-
include tox.ini
3-
include requirements/*.txt
2+
include uv.lock
43
graft docs
54
prune docs/_build
65
graft tests

0 commit comments

Comments
 (0)