aspect-build / aspect-build/rules_py

[FR]: A first-party wheel rule that builds with uv's backend

Open
#1,480 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
145
Forks
97
Avg merge
1d 1h
Merged PRs (30d)
71

Description

### What is the current behavior?

py_wheel is re-exported verbatim from rules_python (py/defs.bzl:49), and takes the distribution's identity and metadata as rule attributes: distribution, version, requires, entry_points, classifiers, summary, license, project_urls, python_requires.

All of those facts are already in pyproject.toml, which the uv extension reads to resolve dependencies. A uv project that also publishes therefore states its metadata twice and has to keep the copies in sync. That is a super big footgun if you build a few wheels.

The user experience is also questionable with the current rules_python py_wheel implementation. I don't quite understand why we need a build backend reimplemented in bazel that is not even PEP compliant.

### Describe the feature

A uv_wheel rule that builds a first-party wheel by running uv build so nothing about the distribution is repeated in the BUILD file:

```
uv_wheel(
name = "wheel",
srcs = ["greeting/banner.txt"], # package data
deps = [":greeting"],
)
```

uv build's backend (build-backend = "uv_build") is compiled into the uv binary, so a pure-Python wheel needs no build dependencies, no Python interpreter and no network:

```
uv build --wheel --no-config --offline --no-cache \
--no-build-isolation --no-python-downloads \
--project --out-dir
```

This would make the whole bazel python work a lot more pythonic and user friendly.

Contributor guide

Open the contributing guide

Research direction

Start at py/defs.bzl:49, where py_wheel is re-exported from rules_python, and review the existing py_wheel interface. Then examine the proposed uv_wheel inputs and the documented uv build command, including staging srcs and producing a wheel offline. Done means a first-party wheel can be built from project metadata without repeating distribution attributes in BUILD files.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.