Skip to content

Commit e01b65b

Browse files
Try switching to UV
The goal of this is to be able to use pinned versions of all files for reproducible development
1 parent 5af3a17 commit e01b65b

File tree

8 files changed

+2883
-77
lines changed

8 files changed

+2883
-77
lines changed

.github/workflows/CI.yml

+28-15
Original file line numberDiff line numberDiff line change
@@ -25,56 +25,69 @@ jobs:
2525
- "3.10"
2626
steps:
2727
- uses: actions/checkout@v4
28+
- uses: astral-sh/setup-uv@v3
29+
with:
30+
enable-cache: true
2831
- uses: dtolnay/[email protected]
2932
- uses: Swatinem/rust-cache@v2
3033
- name: Setup python ${{ matrix.py }}
3134
uses: actions/setup-python@v5
3235
with:
3336
python-version: ${{ matrix.py }}
34-
cache: "pip"
35-
- run: pip install -e .[test]
36-
- run: pytest --benchmark-disable -vvv
37+
- run: uv sync --extra test
38+
- run: uv run pytest --benchmark-disable -vvv
39+
- run: uv cache prune --ci
3740
mypy:
3841
runs-on: ubuntu-latest
3942
steps:
4043
- uses: actions/checkout@v4
44+
- uses: astral-sh/setup-uv@v3
45+
with:
46+
enable-cache: true
4147
- uses: dtolnay/[email protected]
4248
- uses: Swatinem/rust-cache@v2
4349
- uses: actions/setup-python@v5
4450
with:
51+
# Run on oldest Python version to catch more errors
4552
python-version: "3.10"
46-
cache: "pip"
47-
- run: pip install -e .[test] mypy pre-commit
48-
- run: pre-commit run --hook-stage manual --all-files mypy
49-
- run: pre-commit run --hook-stage manual --all-files stubtest
53+
- run: uv sync --extra test
54+
- run: make mypy
55+
- run: make stubtest
56+
- run: uv cache prune --ci
57+
5058
benchmark:
5159
runs-on: ubuntu-latest
5260
steps:
5361
- uses: actions/checkout@v4
62+
- uses: astral-sh/setup-uv@v3
63+
with:
64+
enable-cache: true
5465
- uses: dtolnay/[email protected]
5566
- uses: Swatinem/rust-cache@v2
5667
- uses: actions/setup-python@v5
5768
with:
58-
python-version: "3.12"
59-
cache: "pip"
60-
- run: pip install -e .[test]
69+
python-version-file: ".python-version"
70+
- run: uv sync --extra test
6171
- uses: CodSpeedHQ/action@v3
6272
with:
6373
token: ${{ secrets.CODSPEED_TOKEN }}
64-
run: pytest -vvv -n auto
74+
run: uv run pytest -vvv -n auto
75+
- run: uv cache prune --ci
76+
6577
docs:
6678
runs-on: ubuntu-latest
6779
steps:
6880
- uses: actions/checkout@v4
81+
- uses: astral-sh/setup-uv@v3
6982
- uses: dtolnay/[email protected]
7083
- uses: Swatinem/rust-cache@v2
7184
- uses: actions/setup-python@v5
7285
with:
73-
python-version: "3.10"
74-
cache: "pip"
86+
python-version-file: ".python-version"
7587
- name: Install graphviz
7688
run: |
7789
sudo apt-get update
7890
sudo apt-get install -y graphviz
79-
- run: pip install -e .[docs] pre-commit
80-
- run: pre-commit run --hook-stage manual --all-files docs
91+
- run: uv sync --extra docs
92+
- run: make docs
93+
- run: uv cache prune --ci

.pre-commit-config.yaml

+3-26
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,7 @@ repos:
1010
- id: ruff
1111
args: [--fix, --exit-non-zero-on-fix]
1212
- id: ruff-format
13-
- repo: local
13+
- repo: https://github.com/astral-sh/uv-pre-commit
14+
rev: 0.4.25
1415
hooks:
15-
- id: mypy
16-
name: mypy
17-
entry: dmypy run -- python/
18-
language: system
19-
require_serial: true
20-
pass_filenames: false
21-
stages: [manual]
22-
- repo: local
23-
hooks:
24-
- id: stubtest
25-
name: stubtest
26-
entry: python -m mypy.stubtest egglog.bindings --allowlist stubtest_allow
27-
language: system
28-
pass_filenames: false
29-
require_serial: true
30-
stages: [manual]
31-
- repo: local
32-
hooks:
33-
- id: docs
34-
name: docs
35-
entry: sphinx-build -T -b html docs docs/_build/html
36-
language: system
37-
pass_filenames: false
38-
require_serial: true
39-
stages: [manual]
16+
- id: uv-lock

.readthedocs.yaml

+8-15
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,17 @@ build:
1212
python: "3.12"
1313
# # You can also specify other tool versions:
1414
# # nodejs: "16"
15-
rust: "1.70"
15+
rust: "1.78"
1616
# golang: "1.17"
1717
apt_packages:
1818
- graphviz
19+
commands:
20+
- asdf plugin add uv
21+
- asdf install uv latest
22+
- asdf global uv latest
23+
- uv sync --extra docs --frozen
24+
- uv run -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
25+
1926
# Build documentation in the docs/ directory with Sphinx
2027
sphinx:
2128
configuration: docs/conf.py
22-
23-
# If using Sphinx, optionally build your docs in additional formats such as PDF
24-
# formats:
25-
# - pdf
26-
27-
# Optionally declare the Python requirements required to build your docs
28-
python:
29-
install:
30-
- method: pip
31-
path: .
32-
extra_requirements:
33-
- docs
34-
# conda:
35-
# environment: docs/environment.yml

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ clean:
2626
from-local:
2727
cp ../egraph-visualizer/dist/index.js python/egglog/visualizer.js
2828
cp ../egraph-visualizer/dist/style.css python/egglog/visualizer.css
29+
30+
# remove once https://github.com/astral-sh/uv/issues/5903
31+
32+
mypy:
33+
uv run dmypy run -- python/
34+
35+
stubtest:
36+
uv run python -m mypy.stubtest egglog.bindings --allowlist stubtest_allow
37+
38+
docs:
39+
uv run sphinx-build -T -b html docs docs/_build/html

docs/how-to-guides.md

-9
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,3 @@ commands
1919
```{code-cell}
2020
egraph.run_program(*commands)
2121
```
22-
23-
## Developing this package
24-
25-
To get started developing on this package:
26-
27-
1. Create a Python environment to develop on, either with virtualenv or conda.
28-
2. Install this package in editable mode: `pip install -e .[dev,test]`
29-
3. Run the tests: `pytest`
30-
4. Run the pre-commit hooks: `pre-commit run --all-files`

docs/reference/contributing.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@ gh repo fork egraphs-good/egglog-python --clone
2020
cd egglog-python
2121
```
2222

23-
Then [install Rust](https://www.rust-lang.org/tools/install) and get a Python environment set up with a compatible version. Using [miniconda](https://formulae.brew.sh/cask/miniconda) this would be:
23+
Then [install Rust](https://www.rust-lang.org/tools/install) and get a Python environment set up with a compatible version. Using [uv](https://docs.astral.sh/uv/getting-started/installation/) this would be:
2424

2525
```bash
2626
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
27-
brew install --cask miniconda
28-
conda create -n egglog-python python
29-
conda activate egglog-python
27+
curl -LsSf https://astral.sh/uv/install.sh | sh
3028
```
3129

3230
Then install the package in editable mode with the development dependencies:
3331

3432
```bash
35-
maturin develop -E dev,docs,test,array
33+
uv sync --all-extras
3634
```
3735

38-
Anytime you change the rust code, you can run `maturin develop` to recompile the rust code.
36+
Anytime you change the rust code, you can run `uv sync` to recompile the rust code.
3937

4038
If you would like to download a new version of the visualizer source, run `make clean; make`. This will download
4139
the most recent released version from the github actions artifact in the [egraph-visualizer](https://github.com/egraphs-good/egraph-visualizer) repo. It is checked in because it's a pain to get cargo to include only one git ignored file while ignoring the rest of the files that were ignored.
@@ -45,33 +43,33 @@ the most recent released version from the github actions artifact in the [egraph
4543
To run the tests, you can use the `pytest` command:
4644

4745
```bash
48-
pytest
46+
uv run pytest
4947
```
5048

5149
All code must pass ruff linters and formaters. This will be checked automatically by the pre-commit if you run `pre-commit install`.
5250

5351
To run it manually, you can use:
5452

5553
```bash
56-
pre-commit run --all-files ruff
54+
uv run pre-commit run --all-files ruff
5755
```
5856

5957
If you make changes to the rust bindings, you can check that the stub files accurately reflect the rust code by running:
6058

6159
```bash
62-
pre-commit run --all-files --hook-stage manual stubtest
60+
make stubtest
6361
```
6462

6563
All code must all pass MyPy type checking. To run that locally use:
6664

6765
```bash
68-
pre-commit run --all-files --hook-stage manual mypy
66+
make mypy
6967
```
7068

7169
Finally, to build the docs locally and test that they work, you can run:
7270

7371
```bash
74-
pre-commit run --all-files --hook-stage manual docs
72+
make docs
7573
```
7674

7775
## Making changes

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ array = [
3535
"numba==0.59.1",
3636
"llvmlite==0.42.0",
3737
]
38-
dev = ["pre-commit", "ruff", "mypy", "anywidget[dev]", "egglog[docs,test]"]
38+
dev = ["ruff", "pre-commit", "mypy", "anywidget[dev]", "egglog[docs,test]"]
3939

4040
test = [
4141
"pytest",
@@ -62,6 +62,7 @@ docs = [
6262
"ablog",
6363
]
6464

65+
6566
[tool.ruff.lint]
6667
ignore = [
6768
# Allow uppercase vars
@@ -243,3 +244,6 @@ exclude_also = [
243244
"@(abc\\.)?abstractmethod",
244245
"assert_never\\(",
245246
]
247+
248+
[tool.uv.workspace]
249+
members = ["egglog"]

0 commit comments

Comments
 (0)