Skip to content

Commit 5c45fc5

Browse files
authored
Merge pull request #287 from authzed/283-use-uv-for-dep-management-and-building
Use uv for dependency management and packaging
2 parents efe02b0 + 957ddf6 commit 5c45fc5

File tree

83 files changed

+760
-911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+760
-911
lines changed

.github/workflows/lint.yaml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,6 @@ jobs:
7373
runs-on: "ubuntu-latest"
7474
steps:
7575
- uses: "actions/checkout@v5"
76-
- uses: "actions/setup-python@v6"
77-
with:
78-
python-version: "3.10"
79-
- name: "Setup Python Environment"
80-
run: "pip install -U pip virtualenv"
81-
- name: "Install Dependencies"
82-
run: |
83-
virtualenv ~/.cache/virtualenv/authzedpy
84-
source ~/.cache/virtualenv/authzedpy/bin/activate
85-
pip install poetry
86-
poetry env info
87-
poetry install --only dev
76+
- uses: "astral-sh/setup-uv@v6"
8877
- name: "mypy"
89-
run: |
90-
source ~/.cache/virtualenv/authzedpy/bin/activate
91-
mypy authzed
78+
run: "uv run --frozen mypy src/authzed"

.github/workflows/publish-to-pypi.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,17 @@ jobs:
1010
runs-on: "ubuntu-latest"
1111
steps:
1212
- uses: "actions/checkout@v5"
13-
- name: "Install Poetry"
14-
uses: "snok/install-poetry@v1"
15-
- uses: "actions/setup-python@v6"
16-
with:
17-
python-version: "3.11"
18-
cache: 'poetry'
13+
- uses: "astral-sh/setup-uv@v6"
1914
# This gives us a version number without the release prefix
2015
- name: "Write release version"
2116
run: |
2217
VERSION=${GITHUB_REF_NAME#v}
2318
echo Version: $VERSION
2419
echo "VERSION=$VERSION" >> $GITHUB_ENV
2520
- name: "Set the release number in pyproject.toml"
26-
run: "poetry version -s $VERSION"
21+
run: "uv version $VERSION"
2722
- name: "Build wheel and source tarball"
28-
run: "poetry build"
23+
run: "uv build"
2924
- name: "Publish"
3025
uses: "pypa/gh-action-pypi-publish@release/v1"
3126
with:

.github/workflows/test.yaml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: "Test"
3-
on:
3+
on: # yamllint disable-line rule:truthy
44
push:
55
branches:
66
- "main"
@@ -30,22 +30,12 @@ jobs:
3030
- "3.13"
3131
steps:
3232
- uses: "actions/checkout@v5"
33-
- uses: "actions/setup-python@v6"
34-
with:
35-
python-version: "${{ matrix.python-version }}"
36-
- name: "Setup Python Environment"
37-
run: "pip install -U pip virtualenv"
38-
- name: "Install Dependencies"
39-
run: |
40-
virtualenv ~/.cache/virtualenv/authzedpy
41-
source ~/.cache/virtualenv/authzedpy/bin/activate
42-
pip install poetry
43-
poetry env info
44-
poetry install
4533
- uses: "authzed/action-spicedb@v1"
4634
with:
4735
version: "latest"
48-
- name: "Pytest"
49-
run: |
50-
source ~/.cache/virtualenv/authzedpy/bin/activate
51-
pytest -vv
36+
- name: "Install the latest version of uv and set the python version"
37+
uses: "astral-sh/setup-uv@v6"
38+
with:
39+
python-version: "${{ matrix.python-version }}"
40+
- name: "Run tests"
41+
run: "uv run --frozen pytest"

CONTRIBUTING.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,27 @@ If you have already authored a commit that is missing the signed-off, you can am
6969

7070
### Adding and updating dependencies
7171

72-
This project uses [Poetry] for managing dependencies.
73-
By default, Poetry will create a [virtualenv] for you.
74-
Optionally, we recommend using [pyenv] if you need to manage Python versions as well as virtualenvs.
72+
This project uses [uv](https://docs.astral.sh/uv/) for managing dependencies.
7573

76-
Adding a new dependency can be done with `poetry add` command:
74+
Adding a new dependency can be done with `uv add` command:
7775

7876
```sh
79-
poetry add library
77+
uv add library
8078
```
8179

82-
Updating all dependencies can be done with `poetry update` command:
80+
Updating all dependencies can be done with `uv sync` command:
8381

8482
```sh
85-
poetry update
83+
uv sync
8684
```
8785

88-
For more instructions, see the [Poetry documentation].
86+
Running a command (like `mypy` or `pytest`) can be done with `uv run`:
8987

90-
[poetry]: https://python-poetry.org
91-
[virtualenv]: https://virtualenv.pypa.io/en/latest/
92-
[pyenv]: https://github.com/pyenv/pyenv
93-
[poetry documentation]: https://python-poetry.org/docs/cli
88+
```sh
89+
uv run pytest
90+
```
91+
92+
For more instructions, see the [uv documentation](https://docs.astral.sh/uv/).
9493

9594
### Updating generated Protobuf code
9695

@@ -109,18 +108,20 @@ You can regenerate the code by executing `buf.gen.yaml`:
109108

110109
### Running the Unit tests
111110

112-
1. `poetry install --with dev`
113111
1. `docker run -d -p 50051:50051 -p 50052:50052 --entrypoint spicedb quay.io/authzed/spicedb:latest-debug serve-testing` (or pick a specific version of the spicedb server as appropriate)
114-
1. `poetry run pytest -vv .`
112+
1. `uv run pytest -vv .`
115113

116114
### Passing the linters
117115

118116
See the [lint workflow](/.github/workflows/lint.yaml) for updated steps, but it should look something like this:
119117

120118
```sh
121-
poetry install --with dev
122-
poetry shell
123-
find . -name "*.py" | grep -v "_pb2" | xargs pyflakes
124-
black .
125-
find . -name "*.py" | grep -v "_pb2" | xargs isort
119+
uv run ruff
120+
```
121+
122+
Alternatively, install `ruf` globally and then run directly:
123+
124+
```sh
125+
pipx install ruff
126+
ruff
126127
```

buf.gen.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ version: "v2"
33
plugins:
44
- remote: "buf.build/protocolbuffers/python:v28.3"
55
include_imports: true
6-
out: "."
6+
out: "src"
77
- remote: "buf.build/grpc/python:v1.67.1"
8-
out: "."
8+
out: "src"
99
- remote: "buf.build/community/nipunn1313-mypy:v3.6.0"
1010
include_imports: true
11-
out: "."
11+
out: "src"
1212
inputs:
1313
# NOTE: this references a variant of 1.41.0 that includes the protovalidate code.
1414
- module: "buf.build/authzed/api:v1.45.0"

0 commit comments

Comments
 (0)