-
-
Notifications
You must be signed in to change notification settings - Fork 681
fix: handle unsubstituted template placeholders for external native py_binary #3495
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 9 commits into
bazel-contrib:main
from
thomasdesr:thomas/fix-external-native-py-binary-bootstrap
Jan 25, 2026
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c027306
fix: handle unsubstituted template placeholders for external native p…
thomasdesr 44b9e8a
Fix some AI feedback
thomasdesr dc68724
Finally got pre-commit working
thomasdesr a91096d
fix: add rules_shell dependency to integration test WORKSPACE
thomasdesr ad6659f
fix: skip external_native_py_binary test on Bazel 9+
thomasdesr 3c559ad
refactor: simplify interpreter_args encoding to newline-delimited values
thomasdesr a9a13e3
Merge branch 'main' of https://github.com/bazel-contrib/rules_python …
rickeylev d0ce133
undo changes to stage1_bootstrap_template.sh
rickeylev 12a4ad3
remove tests, add comment about why logic exists
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| sh_test( | ||
| name = "external_native_py_binary_test", | ||
| srcs = ["external_native_py_binary_test.sh"], | ||
| data = [ | ||
| "@bazel_tools//tools/bash/runfiles", | ||
| "@native_py_binary_repo//:external_native_py_binary", | ||
| ], | ||
| env = { | ||
| "BIN_RLOCATION": "native_py_binary_repo/external_native_py_binary", | ||
| }, | ||
| ) |
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,35 @@ | ||
| workspace(name = "external_native_py_binary") | ||
|
|
||
| load( | ||
| "@bazel_tools//tools/build_defs/repo:local.bzl", | ||
| "local_repository", | ||
| "new_local_repository", | ||
| ) | ||
|
|
||
| local_repository( | ||
| name = "rules_python", | ||
| path = "../../..", | ||
| ) | ||
|
|
||
| load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") | ||
|
|
||
| py_repositories() | ||
|
|
||
| python_register_toolchains( | ||
| name = "python_3_11", | ||
| python_version = "3.11", | ||
| ) | ||
|
|
||
| new_local_repository( | ||
| name = "native_py_binary_repo", | ||
| path = "external_repo", | ||
| build_file_content = """ | ||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| py_binary( | ||
| name = "external_native_py_binary", | ||
| srcs = ["main.py"], | ||
| main = "main.py", | ||
| ) | ||
| """, | ||
| ) |
20 changes: 20 additions & 0 deletions
20
tests/integration/external_native_py_binary/external_native_py_binary_test.sh
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,20 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # --- begin runfiles.bash initialization v3 --- | ||
| set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash | ||
| source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ | ||
| source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ | ||
| source "$0.runfiles/$f" 2>/dev/null || \ | ||
| source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
| source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ | ||
| { echo >&2 "ERROR: cannot find $f"; exit 1; } | ||
| set -euo pipefail | ||
| # --- end runfiles.bash initialization v3 --- | ||
|
|
||
| bin=$(rlocation "$BIN_RLOCATION") | ||
| output="$("$bin")" | ||
| if [[ "$output" != "external-native-ok" ]]; then | ||
| echo >&2 "Expected 'external-native-ok' but got: $output" | ||
| exit 1 | ||
| fi |
1 change: 1 addition & 0 deletions
1
tests/integration/external_native_py_binary/external_repo/main.py
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 @@ | ||
| print("external-native-ok") |
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.