bazel-contrib / bazel-contrib/rules_python

Support `uv` as part of `rules_python`

未关闭
#1,975 26 条评论 21 个 reaction 已指派 0 人 在 GitHub 查看
type: feature request type: pip
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

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.

贡献指南

打开贡献指南

调研方向

首先查看当前的检查清单和四种实现方案,然后检查 //python/*.bzl 入口点、WORKSPACE 对 deps.bzl 的支持、bzlmod 集成以及 rules_uv 的发布版本。比较现有的 uv.lock 和 requirements.txt 处理方式以及 example-test 的预期。在项目选择一种方案并明确所需的 WORKSPACE 和 bzlmod 行为之前,不能认为工作已经完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
需要澄清
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。