refactor: add rule to do analysis time evaluation of environment markers#2832
refactor: add rule to do analysis time evaluation of environment markers#2832rickeylev merged 28 commits intobazel-contrib:mainfrom
Conversation
aignas
left a comment
There was a problem hiding this comment.
Shall I push some of my thoughts as code or leave this at a comment level in the PR?
Yes, go ahead and push changes. |
rickeylev
left a comment
There was a problem hiding this comment.
mapped in the various things. added 2 flags.
|
As I've poked around the various pep508.bzl files, I see there's a lot of little utilities, tests, edge cases, etc. I'm just plowing ahead and copy/pasting things. Feel free to point out specific places where something should be wired into something else |
|
Ok, basic flag with tests is working. Based on the convo in the other issue, it's pretty clear I didn't understand the jargon and renaming things is in order. |
|
renamed to env_marker_setting, since it's all about evaluate env markers. Saw this comment you added:
I think there are android-specific flags in the android rules that could tell that info. However, we wouldn't want to depend on the android rules. If we want to cleanly support this, then a toolchain would probably be best. The way it could work is using toolchains in a plugin model type of way. Depending on the android rules runs their MODULE.bazel, which registers e.g. |
|
How is the |
|
Well, this started as a prototype, but it's actually functional now! PTAL We could probably skip straight to analysis time dependency selection when the rest of the rest of the starlark pep 508 functionality is ready. I was trying to figure out how to re-activate those code paths for testing, but it wasn't immediately obvious. |
Yeah, |
Regarding this, I think you are right, we should go straight to |
| "@platforms//os:freebsd": "freebsd", | ||
| "@platforms//os:openbsd": "openbsd", |
There was a problem hiding this comment.
If I am reading it correctly, this value might be freebsd8 and I am wondering if we should do some trickery to combine this value with the platform_release?
There was a problem hiding this comment.
The docs give "freebsd8" as an example from combining the uname calls. We don't know what freebsd version is being targeted, so I think it's best to just omit the version entirely.
re: combining with platform_release: platform_release is so poorly defined I don't think that's a good idea. In order to make it work, it'd have to be specific to a particular platform, i.e. the equivalent of "if //os:freebsd -> then concat('freebsd', $platform_release)". (Possible to express using select(), but if we go through that length, adding it to the toolchain is better IMHO).
The most correct thing would be to get the "undefined" cases from the toolchain; that's the best equivalent of "value when python was built".
My 2c is that extras are more appropriate for to be passed as flags. And markers are more appropriate to be mapped from platforms. Extras are generally user provided and markers are generally build system / environment provided. |
|
I pulled out the newly added flags soas not to affect the public API for now. PTAL I'll send a separate PR to factor out a common "env marker config" thing, as described in #2826 (comment) |
aignas
left a comment
There was a problem hiding this comment.
LGTM other than the map/value duplication, but that is reasonably easy to fix, I think.
aignas
left a comment
There was a problem hiding this comment.
Since factoring out is in the separate PR. Feel free to do the value/map deduping in that PR as well.
wip/prototype to help bootstrap the impl of an analysis-time flag that evaluates
the pep508 dep specs
Creating a PR to make collab easier (maintainers can directly edit)
TODO:
Work towards #2826