Skip to content

py_wheel#requires only accepts a hard-coded dependency list #994

@alexeagle

Description

@alexeagle

When building a Wheel, you want to populate the Requires-Dist lines in the mylib.dist-info/METADATA file so that users of the wheel have the dependencies installed.

We support this here: https://github.com/bazelbuild/rules_python/blob/1487a0c416be8bb5d1033b3815fb662527c99197/python/packaging.bzl#L191

This is the attribute documentation:
https://github.com/bazelbuild/rules_python/blob/main/docs/packaging.md#py_wheel-requires

The problem is we force you to encode the dependency list as a string_list attr in your BUILD file. This duplicates information Bazel already knew about the transitive dependencies of the py_libraries, and makes a maintenance burden for users to keep the lists in-sync.

A couple of proposals to improve this:

  • requires could accept a label which is a list of requirements produced by some other action
  • py_wheel could run an aspect up the deps tree to collect the correct resolved requirements itself

One problem I see is that Bazel will have an exact resolved version, say numpy==1.21.6 but libraries should never ship exact constraints as it makes it impossible for consuming applications to solve their constraints. We'd want to propagate the constraint the library author wrote instead, like numpy >= 1.21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions