bazel-contrib / bazel-contrib/rules_python

Support `uv` as part of `rules_python`

Ouverte
#1,975 26 commentaires 21 réactions 0 personnes assignées Voir sur GitHub
type: feature request type: pip
Langage dominant
Starlark
Étoiles
688
Forks
721
Merge moyen
15 h 7 min
PR mergées (30 j)
76

Description

Just creating this as a placeholder for discussions and documenting some thoughts/findings. `rules_uv` is doing its job well and replicating the functionality in `rules_python` would be duplicate effort. However, `rules_uv` does not support `WORKSPACE` installations (at least the [releases] don't advertise such support) and `rules_python` needs to support `WORKSPACE` installations.

[releases]: https://github.com/theoremlp/rules_uv/releases

As a result I see the following options:
1. Do not support `uv`. This has a drawback of longer compilation times with the included `pip-compile` tooling. `uv` is just a binary and could in theory be later reused for common operations with whl packages.
2. Support `uv` only on `bzlmod` by including `rules_uv` as a dependency. This would require us to expose `rules_uv` via `@python_versions` or something similar so that we don't have loads that load `rules_uv` within the main `//python/*.bzl` files to avoid breaking `WORKSPACE` users. However this would not allow us to use it for our own example testing because they should produce the same output with and without bzlmod. Since we cannot dog-food `rules_uv`, it makes it a hard proposition.
3. Write the `WORKSPACE` `deps.bzl` implementation for `rules_uv` so that we can depend on it.
4. Support `uv` by copying/reimplementing the `uv` support as a separate rule/macro whilst not relying on `rules_uv`. The drawback is that we would have to reimplement parts of it, but the benefit would be that the extra tests that we would need to have would be next to the implementation. We could also provide Windows support in this way as `rules_uv` does not support Windows yet due to relying on `bash` scripting for `pip_compile`.

Current status:
- [x] `uv pip compile`, works with custom authentication helpers.
- [x] `uv lock`, works with custom authentication helpers.
- [x] Parse `uv.lock` and support `requirements.txt` feature subset, works with bazel downloader, no sdist support.
- [x] Downloading and customizing downloaded `uv` versions.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par examiner la checklist actuelle et les quatre options d’implémentation, puis inspectez les points d’entrée //python/*.bzl, la prise en charge de deps.bzl par WORKSPACE, l’intégration de bzlmod et les releases de rules_uv. Comparez la gestion existante de uv.lock et requirements.txt ainsi que les attentes des example-test. La tâche n’est pas considérée comme terminée tant que le projet n’a pas choisi une approche et spécifié le comportement requis pour WORKSPACE et bzlmod.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
build-system
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
Calme
Clarté
À clarifier
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.