generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle a system interpreter path on the toolchain (#313)
Handles the path being given to the Python toolchain being a system interpreter. Closes #302 --- ### Type of change - Bug fix (change which fixes an issue) **For changes visible to end-users** - Suggested release notes are provided below: Correctly handle a system interpreter path being set on a Python toolchain. ### Test plan - Covered by existing test cases - Manual testing; please provide instructions so we can reproduce: Manual testing with local interpreter. --------- Co-authored-by: Alex Eagle <[email protected]>
- Loading branch information
Showing
11 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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,2 @@ | ||
# Under Bazel 7 or later, this flag is ignored as the PyRuntimeInfo gives this information. | ||
common --@aspect_rules_py//py:interpreter_version=3.9.6 |
This file contains 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 @@ | ||
../../.bazelversion |
This file contains 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,30 @@ | ||
load("@aspect_rules_py//py:defs.bzl", "py_test") | ||
load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair") | ||
|
||
py_runtime( | ||
name = "py3_runtime", | ||
interpreter_path = "/usr/bin/python3", | ||
interpreter_version_info = { | ||
"major": "3", | ||
"minor": "9", | ||
"micro": "6", | ||
}, | ||
python_version = "PY3", | ||
) | ||
|
||
py_runtime_pair( | ||
name = "py_runtime_pair", | ||
py2_runtime = None, | ||
py3_runtime = ":py3_runtime", | ||
) | ||
|
||
toolchain( | ||
name = "default", | ||
toolchain = ":py_runtime_pair", | ||
toolchain_type = "@bazel_tools//tools/python:toolchain_type", | ||
) | ||
|
||
py_test( | ||
name = "bin", | ||
srcs = ["__main__.py"], | ||
) |
This file contains 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,25 @@ | ||
"Bazel dependencies" | ||
bazel_dep(name = "aspect_rules_py", dev_dependency = True, version = "0.0.0") | ||
|
||
local_path_override( | ||
module_name = "aspect_rules_py", | ||
path = "../..", | ||
) | ||
|
||
# Because we use a prerelease of rules_py, we must compile the rust tools from source. | ||
bazel_dep(name = "rules_rust", version = "0.40.0") | ||
|
||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain( | ||
edition = "2021", | ||
versions = ["1.74.1"], | ||
) | ||
use_repo(rust, "rust_toolchains") | ||
register_toolchains("@rust_toolchains//:all") | ||
|
||
#---SNIP--- Below here is re-used in the snippet published on releases | ||
# Minimum version needs: | ||
# feat: add interpreter_version_info to py_runtime by @mattem in #1671 | ||
bazel_dep(name = "rules_python", dev_dependency = True, version = "0.29.0") | ||
|
||
register_toolchains("//:default") |
This file contains 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,4 @@ | ||
# Test system interperter | ||
|
||
This is a minimal test that rules_py can use a toolchain that relies on the system interpreter. | ||
Note that this is setup to run on Aspect's CI, and locally on a MacOS, paths may vary on your system if running this. |
This file contains 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 @@ | ||
assert 1 == 1 |
This file contains 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 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 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 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