-
-
Notifications
You must be signed in to change notification settings - Fork 631
feat(toolchains): let local toolchains point to a label #3304
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
rickeylev
merged 15 commits into
bazel-contrib:main
from
rickeylev:tests.use.pbs.for.local.toolchain
Oct 1, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a93fcaf
feat(toolchains): let local toolchains point to a label
rickeylev f028ccc
fix sha key, add some doc, remove unneeded use_repo
rickeylev fe58593
make error message nicer
rickeylev 933344e
fix attr spelling
rickeylev 7156b57
implement some probing for windows
rickeylev d3d9f5f
fix error message
rickeylev 8b97dc1
format and fix py code
rickeylev b1387c7
fix error message more
rickeylev 9aee1c3
use correct mac os x string
rickeylev 64be885
actually go up a dir when looking
rickeylev c9ef8f8
call correct path get_child function
rickeylev 822f1d8
convert bin/python3 to python.exe
rickeylev 82c7b7e
remove strip prefix arg, not used, causes error
rickeylev 0ec5d07
add missing workspace config
rickeylev 09b126e
Merge branch 'main' of https://github.com/bazel-contrib/rules_python …
rickeylev 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
File renamed without changes.
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,53 @@ | ||
"""A repository rule to download and extract a Python runtime archive.""" | ||
aignas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
BUILD_BAZEL = """ | ||
# Generated by pbs_archive.bzl | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
exports_files(glob(["**"])) | ||
""" | ||
|
||
def _pbs_archive_impl(repository_ctx): | ||
"""Implementation of the python_build_standalone_archive rule.""" | ||
os_name = repository_ctx.os.name.lower() | ||
urls = repository_ctx.attr.urls | ||
sha256s = repository_ctx.attr.sha256 | ||
|
||
if os_name not in urls: | ||
fail("Unsupported OS: '{}'. Available OSs are: {}".format( | ||
os_name, | ||
", ".join(urls.keys()), | ||
)) | ||
|
||
url = urls[os_name] | ||
sha256 = sha256s.get(os_name, "") | ||
|
||
repository_ctx.download_and_extract( | ||
url = url, | ||
sha256 = sha256, | ||
) | ||
|
||
repository_ctx.file("BUILD.bazel", BUILD_BAZEL) | ||
|
||
pbs_archive = repository_rule( | ||
implementation = _pbs_archive_impl, | ||
attrs = { | ||
"sha256": attr.string_dict( | ||
doc = "A dictionary of SHA256 checksums for the archives, keyed by OS name.", | ||
mandatory = True, | ||
), | ||
"urls": attr.string_dict( | ||
doc = "A dictionary of URLs to the runtime archives, keyed by OS name (e.g., 'linux', 'windows').", | ||
mandatory = True, | ||
), | ||
}, | ||
doc = """ | ||
Downloads and extracts a Python runtime archive for the current OS. | ||
This rule selects a URL from the `urls` attribute based on the host OS, | ||
downloads the archive, and extracts it. | ||
""", | ||
) |
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,19 @@ | ||
import os.path | ||
import shutil | ||
import subprocess | ||
import sys | ||
import tempfile | ||
import unittest | ||
|
||
|
||
class RepoToolchainTest(unittest.TestCase): | ||
maxDiff = None | ||
|
||
def test_python_from_repo_used(self): | ||
actual = os.path.realpath(sys._base_executable.lower()) | ||
# Normalize case: Windows may have case differences | ||
self.assertIn("pbs_runtime", actual.lower()) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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.