-
Notifications
You must be signed in to change notification settings - Fork 541
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
feat(bzlmod): support cross-platform whl setups within the main hub repo #1837
Conversation
I think I've identified at least multiple changes that can be separate PRs:
|
6c19b7b
to
6ad9f4a
Compare
@dougthor42, if you have time, I'd be curious if you could try this PR, It may have the same issue as #1917, but if does not, then it would be a really interesting data point. |
A different error than previously seen. This one is:
Some of our internal packages include the short git commit hash in their wheel name. |
a28c081
to
1c87068
Compare
This still needs an updated git commit message and more docs, but the functionality is there and is covered by tests, so it should be ready to test/review. I'll add more docs later. Sorry for the big PR, but I am not sure if it is possible to split it without loosing the context that is happening all over the This should be portable to the |
Right now the only tests that fail are on Windows and they fail with a weird:
I'll finish here for the day. I might split out the last commit out as a separate PR since that is a small distinct change that is related to the big multi-platform change, but we can land it separately. |
411ac31
to
da00b0a
Compare
…lled With this PR we can finally have fewer lock file entries in setups which do not use the `experimental_index_url` feature yet. This is fully backwards compatible change as it relies on `bazel` doing the right thing and regenerating the lock file. Fixes bazelbuild#1643.
Done, split out the lock-file related work into #1937, so once that one is merged, the diff here will shrink a tiny bit, but not by much. |
The `uv pip install` would only warn the user of yanked packages but would not refuse to install them. Update our implementation to better match the same behaviour.
A previous PR has added the support for passing it in the `requirements_by_platform` and this just add the necessary code to make sure that we can also do the dependency management when parsing the `whl` `METADATA` files.
…ndows This fixes a small issue with our dependency configuration for the documentation building. It is missing `colorama` and probably a few other dependencies to work on windows, but I am not sure if the other `sphinx` machinery supports non UNIX.
With this we can ensure that the name is unique (we use `sha256` and prefix it with `pip_hub` repo), valid (we use `sha256` instead of the version or the build tag of the whl filename) and easy to understand (we add the python tag, abi tag and platform tags to the end of the name to ensure that users have an easy way to navigate the files).
This also changes `is_python_config_setting` so that it can accept extra `flag_values` so that we can reuse it for the cases where we want something that is more specific than `is_python_config_setting` with a `python_version` alone.
…ames This code will use the config settings generated by `pip_config_settings` in all cases and when the `whl_alias` instances are generated by passing `filename` values, then we will also use the platform-specific config settings from the `//_config` package in the hub repo.
With this we start using the `py_linux_libc` flag value in toolchains as well and ensure that no hermetic toolchain will be matched when we specify to pull the `musl` wheels. In that case the user will need to supply their own toolchain that is the expected behaviour. However, I am not sure how we could fail due to no available toolchain in that case because the autodetecting toolchain will just use the host interpreter.
This feature leverages all of the foundational work from previous commits and updates the tests and documentation.
da00b0a
to
bf4c35c
Compare
Merged the main since I saw some |
|
||
def _test_simple(env): | ||
got = pip_repo_name("prefix", "foo-1.2.3-py3-none-any.whl", "deadbeef") | ||
env.expect.that_str(got).equals("prefix_foo_py3_none_any_deadbeef") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using sha is good enough for the first pass, but PR welcome for including the version (and optionally the build tag) in the repo name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to keep this experimental until we settle on the names. Or at least remember to update if we change it and it breaks for users.
} | ||
) | ||
|
||
def pip_config_settings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a good alternative to the current is_python_config_setting
implementation as it would reduce the number of flags that we generate.
# | ||
# If the toolchain is not resolved then you will have a weird message telling | ||
# you that your transition target does not have a PyRuntime provider, which is | ||
# caused by there not being a toolchain detected for the target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests were working previously because even though the test is setting a specific python_version
via a transition, the toolchain that we were getting was the default version. So in this case the actual version would be returned would be different from the one requested in the transition.
This could explain some of the issues we've seen recently about people saying that the toolchain is mismatching their configuration as it could happen if they do not configure the default toolchain version in their MODULE.bazel
file.
I wonder if this should be mentioned in the CHANGELOG.md
. I'll do it for the sake of posterity.
Still failing on the It's a different failure, though, so that's good! $ bazel clean; bazel build //...
INFO: Invocation ID: cefb7077-a468-4283-b711-06897aff5e1d
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
INFO: Invocation ID: 84fe841f-1ab2-4990-9261-165044c971ac
ERROR: /usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~~pip~pypi/_config/BUILD.bazel: no such target '@@rules_python~~pip~pypi//_config:is_py311_none_manylinux_x86_64': target 'is_py311_none_manylinux_x86_64' not declared in package '_config' defined by /usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~~pip~pypi/_config/BUILD.bazel (did you mean is_py3_none_manylinux_x86_64, _is_py3_none_manylinux_x86_64, is_py_none_manylinux_x86_64, _is_py_none_manylinux_x86_64, is_cp3x_none_manylinux_x86_64, or is_py3_none_any_linux_x86_64?)
ERROR: /usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~~pip~pypi/foobar/BUILD.bazel:53:6: errors encountered resolving select() keys for @@rules_python~~pip~pypi//foobar:whl
Use --verbose_failures to see the command lines of failed build steps.
ERROR: Analysis of target '//:modules_map' failed; build aborted: Analysis failed
INFO: Elapsed time: 1.091s, Critical Path: 0.63s
INFO: 18 processes: 18 internal.
ERROR: Build did NOT complete successfully |
…rom dist filenames
@dougthor42, sorry for that one, now should be fixed |
Yup! 445337e worked for me 👍 I noticed that the runfiles directory now has more info in the path name:
-test.runfiles/rules_python~~pip~pypi_311_foobar/
+test.runfiles/rules_python~~pip~pypi_311_foobar_py311_none_manylinux_2_17_x86_64_b7d2f441/ These are great changes! Super useful. Should such a change be included in the changelog? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As mentioned at the maintainers review, we might need to keep exploring alternatives for the explosion of config flags, but I don't think it needs to be blocking while we iterate.
elif set_python_version_constraint == "False": | ||
target_settings = [] | ||
target_settings = [name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The absence of this branch is the root cause of #1967.
…ames Initially the repo name generate was very conservative and we had sha256 as the endings of the repo names. With this change we have more human readable repository names. In order to still comply with the bazel label rules, we are normalizing the versions to only have `_` and `.` characters. This is an alternative fix to the error message seen in bazelbuild#1837 (comment)
With this change we add support for platform-specific wheel registration and
doing the selection of which wheel is used at build time.
This supports:
musl
vsglibc
selection.Summary of changes:
uv pip install
would only warn the user of yanked packages butwould not refuse to install them. Update our implementation to better
match the same behaviour.
requirements_by_platform
and this just add the necessary code to makesure that we can also do the dependency management when parsing the
whl
METADATA
files.dev_pip
deps forlinux
andosx
platforms to not raiseissues later.
whl_library
name from afilename
.render_pkg_aliases
to also use those config settings.target_settings
to use thepy_linux_libc
config setting. With this the user can register a
musl
linux toolchain ifneeded. We can also use similar
flag_values
to resolve Consider supporting armv7-unknown-linux-gnueabi/hf toolchain #1876.pip
extension and setup cross-platformselect statements.
Work towards #1357, #260
Stacked on #1937