-
-
Notifications
You must be signed in to change notification settings - Fork 594
feat(uv): parse the dist-manifest.json to not hardcode sha256 in rules_python #2578
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
Merged
Merged
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
902502c
feat(uv): allow specifying any uv version to use
aignas 57377a8
update the example
aignas b8fa595
cleanup
aignas 8548c69
add a note
aignas 1be7704
Merge branch 'main' into feat/improve-uv-mgmt
aignas 503a956
Merge branch 'main' into feat/improve-uv-mgmt
aignas 069a04c
update changelog
aignas e46d8eb
more cleanup
aignas 6b675f0
add a comment
aignas 4b709f1
add docs
aignas 49b586b
Merge branch 'main' into feat/improve-uv-mgmt
aignas f29c585
wip
aignas 79855d2
wip
aignas 9a79668
wip
aignas 1ac0437
finish a test
aignas 76d581c
Allow specifying the URL and sha256 values manually
aignas 79f3a3d
docs
aignas a1a4072
fixup the tests
aignas a4f2cf8
add docs
aignas c4c8105
cleanup the handling of urls and do not download unnecessary sha256 f…
aignas df80ed8
improve docs
aignas 832007c
simplify and reuse code
aignas 8076549
more cleanup
aignas 0ea9494
bump the default uv version to 0.6.3
aignas 8d9eda6
Merge branch 'main' into feat/improve-uv-mgmt
aignas 9382f6a
rename parse_modules to process_modules and create hub repo in it.
aignas 2f7c38d
update the return value doc
aignas 472f5fa
document the builder dicts
aignas 18db761
ignore calls from non-rules_python non-root modules
aignas 77672e6
ensure that default keys are set
aignas e66834c
base_url defalut setting
aignas b3dccf7
rename '_attr' to 'tag'
aignas 5deabba
remove guard
aignas 8eff080
use a list
aignas ef90b2f
document the file format
aignas 3367366
buildifier errors
aignas d07de0b
rename toolchain_labels
aignas 479449a
document version
aignas 9ed3b7c
rename toolchain_labels to toolchain_implementations and remove uv_re…
aignas 019c6a1
add an analysis test to check lexicographical registration order
aignas 621b80d
attempt to clarify the documentation wording.
aignas 929b3e4
cleanup docs
aignas f63d453
improve the toolchain hub generation
aignas f82fc81
further cleanup
aignas e61a251
add documentation
aignas d00ee31
fix the toolchains registration and document the algorithm
aignas 52db4c9
Merge branch 'main' into feat/improve-uv-mgmt
aignas f2b8ad7
add a test for non-root modules
aignas c2f76d8
ensure rules_python never overrides settings from the root module
aignas 3cd8e4d
address review comments
aignas c2ed9ae
buildifier
aignas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2025 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""A macro used from the uv_toolchain hub repo.""" | ||
|
||
load(":toolchain_types.bzl", "UV_TOOLCHAIN_TYPE") | ||
|
||
def toolchains_hub( | ||
*, | ||
name = None, | ||
toolchains, | ||
implementations, | ||
target_compatible_with, | ||
target_settings): | ||
# @unnamed-macro | ||
"""Define the toolchains so that the lexicographical order registration is deterministic. | ||
|
||
TODO @aignas 2025-03-09: see if this can be reused in the python toolchains. | ||
|
||
Args: | ||
name: The prefix to all of the targets, which goes after a numeric prefix. | ||
toolchains: The toolchain names for the targets defined by this macro. | ||
The earlier occurring items take precedence over the later items if | ||
they match the target platform and target settings. | ||
implementations: The name to label mapping. | ||
target_compatible_with: The name to target_compatible_with list mapping. | ||
target_settings: The name to target_settings list mapping. | ||
""" | ||
if len(toolchains) != len(implementations): | ||
fail("Each name must have an implementation") | ||
|
||
# We are defining the toolchains so that the order of toolchain matching is | ||
# the same as the order of the toolchains, because: | ||
# * the toolchains are matched by target settings and target_compatible_with | ||
# * the first toolchain satisfying the above wins | ||
# | ||
# this means we need to register the toolchains prefixed with a number of | ||
# format 00xy, where x and y are some digits and the leading zeros to | ||
# ensure lexicographical sorting. | ||
# | ||
# Add 1 so that there is always a leading zero | ||
prefix_len = len(str(len(toolchains))) + 1 | ||
prefix = "0" * (prefix_len - 1) | ||
|
||
for i, toolchain in enumerate(toolchains): | ||
# prefix with a prefix and then truncate the string. | ||
number_prefix = "{}{}".format(prefix, i)[-prefix_len:] | ||
|
||
native.toolchain( | ||
name = "{}_{}_{}".format(number_prefix, name, toolchain), | ||
target_compatible_with = target_compatible_with.get(toolchain, []), | ||
target_settings = target_settings.get(toolchain, []), | ||
toolchain = implementations[toolchain], | ||
toolchain_type = UV_TOOLCHAIN_TYPE, | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.