-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py_wheel#requires only accepts a hard-coded dependency list #994
Comments
This is hard to observe in rules_python because our example is contrived: https://github.com/bazelbuild/rules_python/blob/main/examples/wheel/BUILD.bazel#L132 has the |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
In rules_zapp I "solved" this problem by authoring a zipapp "compiler" whose primary purpose is to have special knowledge of the structure of a |
Has anyone put any more thought into this? At least from my perspective this significantly hampers the usefulness of |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
I don't think that satisfies this FR, no. It's interesting if every service in a monorepo maintains a requirements.in file. But
That said, such an ability is perhaps useful for us to layer on top. A Bazel user could have their own macro that invokes a rule with an aspect to collect the actual runtime deps of the |
In our project I added a test target in our py_wheel macro that uses an aspect to extract the transitive deps, and validates that against the passed requires list. Not as nice as generating the file all together, but it at least serves as a guard rail. I think you could generate the file with the aspect similarly, but the thing I'm not sure about is how we would include the version constraints that you want if we were to do that. |
@keith, what does the aspect rely on when inspecting the transitive deps? Is there anything in rules_python that we can do to make it easier to work with and more maintainable in the long term? |
Right now it's pretty fragile and is just using the hardcoded hub name pattern we're using. It would be helpful if I could get the requirement name directly from the deps, (the undocumented I'm not sure what to think about the version constraint, because depending on what you do with the wheel you might not want that to match your in-repo constraints either, so I think re-writing that is probably the best option. |
When building a Wheel, you want to populate the
Requires-Dist
lines in themylib.dist-info/METADATA
file so that users of the wheel have the dependencies installed.We support this here:
rules_python/python/packaging.bzl
Line 191 in 1487a0c
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:
deps
tree to collect the correct resolved requirements itselfOne 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, likenumpy >= 1.21
.The text was updated successfully, but these errors were encountered: