Skip to content

Commit 8c8715e

Browse files
Convert from pipenv to uv (#335)
[uv][1] is a better, faster version of pipenv for managing python projects. The expectation here is similar to `pipenv`, in that developers will install `uv` locally; I haven't pinned a particular version as we aren't doing anything complicated (yet). Can pin a version later if necessary. The only thing left that we may want to do here is to use `uv` as our [build backend](https://docs.astral.sh/uv/concepts/build-backend/), which would eliminate our use of `hatch`, but uv doesn't have [dynamic version resolution from vcs](astral-sh/uv#14137) right now (which is how we currently do our releases), so holding off on that for the time being. [1]: https://docs.astral.sh/uv/
1 parent 0f63813 commit 8c8715e

File tree

11 files changed

+455
-451
lines changed

11 files changed

+455
-451
lines changed

.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7-
- package-ecosystem: "pip"
7+
- package-ecosystem: "uv"
88
directory: "/"
99
schedule:
1010
interval: "weekly"

.github/workflows/ci.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ jobs:
2727
uses: actions/setup-go@v5
2828
with:
2929
go-version: stable
30-
- name: Install Python ${{ matrix.python-version }}
31-
id: python
32-
uses: actions/setup-python@v5
30+
cache: false
31+
- uses: astral-sh/setup-uv@v6
3332
with:
3433
python-version: ${{ matrix.python-version }}
35-
cache: "pipenv"
36-
- run: ${{steps.python.outputs.python-path}} -m pip install --upgrade pip pipenv
3734
- name: Execute tests
38-
run: make test PYTHON=${{ steps.python.outputs.python-path }}
35+
run: make test
3936
- name: Lint
40-
run: make lint PYTHON=${{ steps.python.outputs.python-path }}
37+
run: make lint
4138
- name: Format
42-
run: make format PYTHON=${{ steps.python.outputs.python-path }}
39+
run: make format
4340
- name: Check generated
44-
run: make checkgenerate PYTHON=${{ steps.python.outputs.python-path }}
41+
run: make checkgenerate

.github/workflows/conformance.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ jobs:
2727
uses: actions/setup-go@v5
2828
with:
2929
go-version: stable
30+
cache: false
31+
- uses: astral-sh/setup-uv@v6
3032
- name: Install Python ${{ matrix.python-version }}
31-
id: python
32-
uses: actions/setup-python@v5
33-
with:
34-
python-version: ${{ matrix.python-version }}
35-
cache: "pipenv"
36-
- run: ${{steps.python.outputs.python-path}} -m pip install --upgrade pip pipenv
33+
run: uv python install ${{ matrix.python-version }}
3734
- name: Test conformance
38-
run: make conformance PYTHON=${{ steps.python.outputs.python-path }}
35+
run: make conformance

.github/workflows/release.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@ jobs:
1919
run: |
2020
VERSION=${{github.head_ref}}
2121
echo "VERSION=${VERSION##*/}" >> $GITHUB_ENV
22-
- name: Set up Python
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: "3.13"
26-
- name: Install pypa/build
22+
- uses: astral-sh/setup-uv@v6
23+
- name: Build release
2724
run: |
28-
python -m pip install build
29-
python -m build
25+
uv build
3026
- uses: actions/upload-artifact@v4
3127
with:
3228
name: package
3329
path: dist/
3430

3531
publish:
32+
# TODO: trusted publisher
33+
# https://docs.astral.sh/uv/guides/publish/#publishing-your-package
3634
name: Publish on PyPI
3735
runs-on: ubuntu-latest
3836
environment:

Makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ MAKEFLAGS += --no-print-directory
99
BIN := .tmp/bin
1010
export PATH := $(BIN):$(PATH)
1111
export GOBIN := $(abspath $(BIN))
12-
# Set to use a different Python interpreter. For example, `PYTHON=python make test`.
13-
PYTHON ?= python3
12+
export PYTHONPATH ?= gen
1413
CONFORMANCE_ARGS ?= --strict_message --expected_failures=tests/conformance/nonconforming.yaml --timeout 10s
1514
ADD_LICENSE_HEADER := $(BIN)/license-header \
1615
--license-type apache \
@@ -47,27 +46,27 @@ generate: $(BIN)/buf $(BIN)/license-header ## Regenerate code and license header
4746
.PHONY: format
4847
format: install $(BIN)/license-header ## Format code
4948
$(ADD_LICENSE_HEADER)
50-
pipenv run ruff format protovalidate tests
51-
pipenv run ruff check --fix protovalidate tests
49+
uv run -- ruff format protovalidate tests
50+
uv run -- ruff check --fix protovalidate tests
5251

5352
.PHONY: test
5453
test: generate install gettestdata ## Run unit tests
55-
pipenv run pytest
54+
uv run -- pytest
5655

5756
.PHONY: conformance
5857
conformance: $(BIN)/protovalidate-conformance generate install ## Run conformance tests
59-
protovalidate-conformance $(CONFORMANCE_ARGS) pipenv -- --python $(PYTHON) run python3 -m tests.conformance.runner
58+
protovalidate-conformance $(CONFORMANCE_ARGS) uv -- run python3 -m tests.conformance.runner
6059

6160
.PHONY: lint
6261
lint: install ## Lint code
63-
pipenv run ruff format --check --diff protovalidate tests
64-
pipenv run mypy protovalidate
65-
pipenv run ruff check protovalidate tests
66-
pipenv verify
62+
uv run -- ruff format --check --diff protovalidate tests
63+
uv run -- mypy protovalidate
64+
uv run -- ruff check protovalidate tests
65+
uv sync --locked
6766

6867
.PHONY: install
6968
install: ## Install dependencies
70-
pipenv --python $(PYTHON) sync --dev
69+
uv sync --dev
7170

7271
.PHONY: checkgenerate
7372
checkgenerate: generate

Pipfile

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

0 commit comments

Comments
 (0)