-
-
Notifications
You must be signed in to change notification settings - Fork 594
Proposal for simplifying pip dependencies #822
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
Comments
Update: I don't think it's possible to use a downloaded python interpreter. Or at least, you can use one, but it'll be platform specific. |
Yes, I agree with you on many points. As a maintainer group we are trying to cleanup the mistakes of the past #807 while also not breaking things too rapidly for existing users. I too believe the rules should remove most of the eager work happening in repository rules and move a lot closer to rules_jvm_external. For my own research:
|
I would like to add to @pauldraper's points - An alternate integration of And @groodt, to chime in on your questions:
|
Thanks for the work on #807 ! I agree that is in the right direction. I suggest further:
@FaQA further suggests:
|
@pauldraper could you point to more info about why vendoring the requirements.bzl is required for bzlmod to work? It is because the MODULE.bazel file has to repeat the list of dependencies in We'll run into the same thing in rules_js https://github.com/aspect-build/rules_js/tree/main/docs#fetch-third-party-packages-from-npm where we still recommend both vendoring and translate-on-the-fly options. |
This is similar to what I've slowly been working on over at rules_pycross, although I'm piggybacking on Poetry's ability to create cross-platform lock files. I added keyring to example_lock.bzl. |
@FaQA Thanks for your input. Agree that in an ideal world, the full transitive dependency graph for all python runtimes of the user's monorepo would be materialised ahead of time as targets in a @pauldraper Thanks for your input. As mentioned above, largely agree with your primary points. Just for some further clarifications: |
I can't recall the details right now, but IIRC it's basically the fact that most repos operate like create_repo()
load("@repo//:rules.bzl", "deps")
deps() but that repo has pip dependencies, it needs a double step. create_repo()
load("@repo//:rules.bzl", "deps")
deps()
load("@pip_repo//:rules.bzl", "pip_deps")
pip_deps() I admit I could be wrong about that however. |
@groodt - Thanks for responding! I am aware of the the If you use |
@FaQA Can you please create a repro for the situation you describe? If you're generating platform specific lockfiles, then the situation you describe sounds like a bug. I'm not sure about the genquery part though, genquery has a number of "quirks" so I'm not even sure how well it supports |
@groodt - I realized I never got back with a reproduction of the issue! Sorry, here it is - https://github.com/Faqa/rules_python_cross_repro. If you try building the repository there in a Linux env (I've attached a Basically, as you say, |
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. |
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?" |
Uh oh!
There was an error while loading. Please reload this page.
Problem
Pip dependencies are implemented awkwardly, causing all sort of caveats.
For example:
Pip dependencies by default don't work with bzlmod. You have to vendor requirements.bzl.
But vendoring is awkward and requires minimum two
bazel
runs to work (update lockfile, then re-run repos and copy bzl).And it turns out requirements.bzl doesn't work with annotations anyway (Cannot use annotations with vendored requirements.bzl #821).
And you spend an hour figuring all that out because the implementation is so dang overcomplicated.
Probably more too, I just haven't gotten to them yet.
Solution
The core problem is doing stuff in repository rules. You should really do as little as possible in repository rules. Repository rules are for downloading things, and hacky non-hermetic one-offs. It's handicap, and jumping through those hoops hurts everything.
Rather, users should always vendor requirements.bzl.
WORKSPACE.bzl
BUILD.bazel
Whenever requirements.in is updated, run
bazel run :pip
to update files. Easy as that.As a benefit, annotations are provided directly to
pip_packages
without shenanigans. (And if there's something advanced not covered by annotations, uses can even consume or modify PIP_PACKAGES itself.)Simple and robust.
The text was updated successfully, but these errors were encountered: