File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ Unreleased changes template.
124
124
* (toolchains) Local Python installs can be used to create a toolchain
125
125
equivalent to the standard toolchains. See [ Local toolchains] docs for how to
126
126
configure them.
127
+ * (toolchains) Expose ` $(PYTHON2_ROOTPATH) ` and ` $(PYTHON3_ROOTPATH) ` which are runfiles
128
+ locations equivalents of ` $(PYTHON2) ` and `$(PYTHON3) respectively.
127
129
128
130
129
131
{#v0-0-0-removed}
Original file line number Diff line number Diff line change @@ -215,7 +215,11 @@ attribute. You can obtain the path to the Python interpreter using the
215
215
` $(PYTHON2) ` and ` $(PYTHON3) ` [ "Make"
216
216
Variables] ( https://bazel.build/reference/be/make-variables ) . See the
217
217
{gh-path}` test_current_py_toolchain <tests/load_from_macro/BUILD.bazel> ` target
218
- for an example.
218
+ for an example. We also make available ` $(PYTHON2_ROOTPATH) ` and ` $(PYTHON3_ROOTPATH) `
219
+ which are Make Variable equivalents of ` $(PYTHON2) ` and ` $(PYTHON3) ` but for runfiles
220
+ locations. These will be helpful if you need to set env vars of binary/test rules
221
+ while using [ ` --nolegacy_external_runfiles ` ] ( https://bazel.build/reference/command-line-reference#flag--legacy_external_runfiles ) .
222
+ The original make variables still work in exec contexts such as genrules.
219
223
220
224
### Overriding toolchain defaults and adding more versions
221
225
Original file line number Diff line number Diff line change @@ -27,11 +27,13 @@ def _current_py_toolchain_impl(ctx):
27
27
direct .append (toolchain .py3_runtime .interpreter )
28
28
transitive .append (toolchain .py3_runtime .files )
29
29
vars ["PYTHON3" ] = toolchain .py3_runtime .interpreter .path
30
+ vars ["PYTHON3_ROOTPATH" ] = toolchain .py3_runtime .interpreter .short_path
30
31
31
32
if toolchain .py2_runtime and toolchain .py2_runtime .interpreter :
32
33
direct .append (toolchain .py2_runtime .interpreter )
33
34
transitive .append (toolchain .py2_runtime .files )
34
35
vars ["PYTHON2" ] = toolchain .py2_runtime .interpreter .path
36
+ vars ["PYTHON2_ROOTPATH" ] = toolchain .py2_runtime .interpreter .short_path
35
37
36
38
files = depset (direct , transitive = transitive )
37
39
return [
@@ -49,6 +51,11 @@ current_py_toolchain = rule(
49
51
other rules, such as genrule. It allows exposing a python toolchain after toolchain resolution has
50
52
happened, to a rule which expects a concrete implementation of a toolchain, rather than a
51
53
toolchain_type which could be resolved to that toolchain.
54
+
55
+ :::{versionchanged} VERSION_NEXT_FEATURE
56
+ From now on, we also expose `$(PYTHON2_ROOTPATH)` and `$(PYTHON3_ROOTPATH)` which are runfiles
57
+ locations equivalents of `$(PYTHON2)` and `$(PYTHON3) respectively.
58
+ :::
52
59
""" ,
53
60
implementation = _current_py_toolchain_impl ,
54
61
attrs = {
You can’t perform that action at this time.
0 commit comments