-
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
Unable to specify base_url in python.toolchain() when using bzlmod #1172
Comments
I have not tried but you need to use an override: https://docs.bazel.build/versions/5.0.0/skylark/lib/globals.html#archive_override |
Thanks Chris. That would make module download itself working, but the issue I have is with toolchains. I can't quite see how with bzlmod on I can set the base_url for all toolchains to be downloaded from. As I said this is useful in case of corporate github caching proxy (like jfrog artifactory). For that matter, I don't see a way to pass via python module extension my own toolchains while in WORKSPACE.bazel that was fairly simple with python_register_toolchains and tool_versions argument. It would be helpful to understand what is the right way to do this type of rules_python customization with bzlmod if it possible at all. I understand this is a work in progress just by looking at #1155 which addresses a different issue of setting hermetic interpreter for pip.parse which I funnily enough also hit when attempted to switch to bzlmod for the first trial. |
So this line defines the toolchain rules_python/examples/bzlmod/MODULE.bazel Line 69 in 6ce2dbe
Then I believe you can use: The use https://docs.bazel.build/versions/5.0.0/skylark/lib/globals.html#archive_override To override where the repo is downloaded from. It is documented here https://docs.bazel.build/versions/5.0.0/bzlmod.html So you would have the following use_repo(python, "python3_x86_64-unknown-linux-gnu")
archive_override("python3_x86_64-unknown-linux-gnu", urls = ["https://my-bcr-repo.com/foo"]) I have not tested this, but this is what the docs say. |
I see, so for windows and darwin builds I will need to repeat this again. Workspace way certainly looks nicer, but oh well. Thanks a lot Chris. Is there any chance that this may become slighly less verbose towards 6.2+? |
@vladmos I am having a very similar issue myself. Have you gotten the archive override to work? The provided snippet does not work form me. Using: bazel_dep(name = "rules_python", version = "0.20.0")
python = use_extension("@rules_python//python:extensions.bzl", "python")
python.toolchain(
name = "python3",
python_version = "3.10.2",
configure_coverage_tool = False,
)
use_repo(python, "python3_toolchains", "python3", "python3_x86_64-lunknown-linux-gnu")
archive_override(module_name = "python3_x86_64-unknown-linux-gnu", urls = ["internal-mirror"]) I get the following issues:
So |
We need to add a base_url argument to the "python" extension. Since I have been poking around this code a lot more, I now understand the code. Here is an outline of the work if someone wants to contribute. We need to add either a rules_python/python/extensions.bzl Line 44 in 0efcd94
Or a We then need to pass that argument into the rules_python/python/extensions.bzl Line 27 in 0efcd94
This will have rules_python/python/repositories.bzl Line 486 in 0efcd94
|
@vadikmironov & @jbgcarnes PTAL at #1216. |
@vadikmironov and @jbgcarnes would you rather use https://blog.aspect.dev/configuring-bazels-downloader or #1216? |
@chrislovecnm I do have the bazel-downloader setup for most things. The issue primarily here is that the SHA is not the same as the ones you have baked into |
I am indifferent really between rewrite and explicit arguments and I was going to check it out and report after seeing the comment yesterday, but maybe there are other reasons why base url was added explicitly in register toolchains call? |
Would single_version_override be a better option? Despite the name, it also allows you to just apply patches to the module. This would allow you to patch just the BASE_URL variable in rules_python. Adding args to
A separate tag class might work better here that is only usable from the root module (i.e.
(or similar; an entire |
Chris, first of all many thanks for starting #1216 . I can confirm that bazel downloader totally solves this with a simple rewrite command. This ticket can be closed if @jbgcarnes has no further comments. The point that @rickeylev brought up would essentially allow to override toolchain packages and their locations for all supported versions and I think that suggestion is really awesome. If Please do let me know what is the preference - close this item and start a new one for |
@rickeylev what do you think? |
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?" |
One extra thing that |
#2222 Has implemented this. |
🐞 bug report
Affected Rule
The issue is caused by the rule: python:extensions.bzlIs this a regression?
Yes, the previous version in which this bug was not present was: works fine without bzlmodDescription
While trying to prepare my test repo for bzlmod switch, I've noticed that it seems to be no longer possible to override base_url location for python toolchains. This is a super useful feature for someone working behind a corporate firewall and maintaining a mirror of python-build-standalone artefacts.🔬 Minimal Reproduction
Following example is perfectly valid when using WORKSPACE.bazel:
but when defining a toolchain in bzlmod, there is simply no parameter to pass base_url value:
🔥 Exception or Error
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_python version:
Anything else relevant?
The text was updated successfully, but these errors were encountered: