rules_py icon indicating copy to clipboard operation
rules_py copied to clipboard

feat(uv): Sdists build on target

Open arrdem opened this issue 2 months ago • 1 comments

As https://peps.python.org/pep-0720/ explains in frustrating detail, there isn't currently a good way to do crossbuilds from one Python platform to another. While many relevant compiled languages (C, Rust, Fortran) can support crossbuilding, the only really sound thing to do is to let python3 -m build do its thing on the target.

So we need to adapt the sdist_build repository rule so that the underlying sdist_build rule is transitioned so that the execution platform matches the target platform.

However we don't want to transition all sdist builds to the target, since most[^1] Python libraries are purelib and doing so would force users of the uv machinery to deploy RBE when they don't strictly need to do so. As a temporary measure, extend the annotations file schema so that individual requirements can be opted into being built on the target.

In the future, we likely want to distribute a standard "database" of such annotations so that users don't have to, and/or adapt the sdist_build repository rule to use a hermetic tar to unzip the downloaded sdist at repo configuration time and check the sdist content for obvious signs of containing C, Cython, Rust or Fortran code.

[^1] Citation needed

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

The uv extension now allows for requirements to be opted into platform-dependent builds in support of native extensions.

Test plan

  • Manual testing

TBD

arrdem avatar Dec 18 '25 00:12 arrdem