Let uv build the extension, so that dev commands need no `--no-project`

Open
#222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
github-actions, python, rust

Research direction

Read pyproject.toml, DEVELOP.md, and the pytest job in .github/workflows/test-python.yml; compare the current setup with the proposed uv settings. Check the stable ABI, free-threaded build, rebuild time, and async feature in this repository. Done when development commands work without --no-project or a separate maturin develop step, and the documented test workflow passes.

Written by the indexing model from the issue text.

Description

[!NOTE]
This issue was written by Claude (Claude Code), at @kylebarron's request.

Problem

Every development command takes --no-project, and the extension is built in a separate maturin develop step. DEVELOP.md explains why:

The --no-project is annoying, but our current setup makes it necessary. Without it, uv tries to build the Rust library in release mode, as a dependency of the project, before it gets to uv sync or uv run.

Proposal

Let uv do that build, and configure it to build what maturin develop builds. Add this to pyproject.toml:

[tool.uv]
# `uv sync` and `uv run` build the extension themselves. These settings make
# that build match `maturin develop`: the dev profile, and the stable ABI so
# that PyO3 is not rebuilt for each new build environment.
config-settings = { build-args = "--profile=dev --features=abi3-py311" }
# Rebuild the extension when the Rust sources change.
cache-keys = [
    { file = "pyproject.toml" },
    { file = "Cargo.toml" },
    { file = "Cargo.lock" },
    { file = "src/**/*.rs" },
]

uv run pytest is then the whole loop. uv builds the extension before it runs the command, and builds it again when a Rust source changes. There is no maturin develop step and no flag.

What was measured

This was measured in another PyO3 and maturin project of ours, with a very small binding crate, on uv 0.13.1 and maturin 1.16. It has not been tried in zarrista. Each row is "edit a Rust source, then run the tests", three times.

Setup Time per edit
maturin develop --uv, then pytest, both with --no-project 0.64 s
uv builds, dev profile only 3.2 s
uv builds, dev profile and the stable ABI 0.56 s
Nothing changed, either setup 0.22 s

The middle row is why abi3-py311 is in build-args. uv builds in a fresh environment each time, and without the stable ABI Cargo rebuilds pyo3-ffi and pyo3 for each one. zarrista has several more crates that depend on PyO3, so the cost there is probably higher than 3 s.

Where the settings apply, from the same test:

Who builds Result
uv sync or uv run in the project Dev build with the stable ABI
A project that depends on the package by path A normal release build; the settings do not leak
uv build in the project Dev build. Release wheels must come from maturin, as python-wheels.yml already does.

What would change here

  • pyproject.toml: the [tool.uv] table above.
  • DEVELOP.md: uv run pytest, uv run ruff check, and so on, with no build step.
  • The pytest job in test-python.yml: uv sync, then uv run pytest. The maturin develop step goes away.
  • The docstrings and docs jobs keep --no-install-package zarrista and --no-project. They skip the build on purpose, because they only read the .pyi stubs.

To check before adopting it

  • Tests would run against a stable-ABI build. That matches the abi3-py311 wheel. The free-threaded cp314t wheel is not a stable-ABI build, so a free-threaded development environment would need the feature turned off, and would pay the PyO3 rebuild on each edit.
  • How long a rebuild takes in zarrista, with and without the stable ABI.
  • The async feature. default = ["async"] stays on, since build-args only adds a feature.
Dominant language
Python
Stars
52
Forks
3
Avg merge
36m
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/zarrista

All issues in developmentseed/zarrista

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.