Skip to content

Commit 7ca9e3f

Browse files
fix(toolchain): Also set Make variables for local toolchains (#3641)
Currently, the toolchain only sets the make variables if it's an in-build toolchain. This breaks for platform toolchains. To fix, check for platform toolchains and set the make vars appropriately. This helps fix the BCR rules for `@glib`, which recently added a requirement that the Make variable `$(PYTHON3)` must always be defined by the current Python toolchain. Co-authored-by: Richard Levasseur <richardlev@gmail.com>
1 parent 67ec8d5 commit 7ca9e3f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ END_UNRELEASED_TEMPLATE
6363

6464
{#v0-0-0-fixed}
6565
### Fixed
66+
* (toolchain) Also set Make variables for local toolchains.
6667
* (zipapp) Resolve issue passing through compression settings in
67-
`py_zippapp_binary` targets. ([#3646](https://github.com/bazel-contrib/rules_python/issues/3646))
68+
`py_zippapp_binary` targets
69+
([#3646](https://github.com/bazel-contrib/rules_python/issues/3646)).
6870

6971
{#v0-0-0-added}
7072
### Added

python/current_py_toolchain.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@ def _current_py_toolchain_impl(ctx):
2828
transitive.append(toolchain.py3_runtime.files)
2929
vars["PYTHON3"] = toolchain.py3_runtime.interpreter.path
3030
vars["PYTHON3_ROOTPATH"] = toolchain.py3_runtime.interpreter.short_path
31+
elif toolchain.py3_runtime and toolchain.py3_runtime.interpreter_path:
32+
vars["PYTHON3"] = toolchain.py3_runtime.interpreter_path
33+
vars["PYTHON3_ROOTPATH"] = toolchain.py3_runtime.interpreter_path
3134

3235
if toolchain.py2_runtime and toolchain.py2_runtime.interpreter:
3336
direct.append(toolchain.py2_runtime.interpreter)
3437
transitive.append(toolchain.py2_runtime.files)
3538
vars["PYTHON2"] = toolchain.py2_runtime.interpreter.path
3639
vars["PYTHON2_ROOTPATH"] = toolchain.py2_runtime.interpreter.short_path
40+
elif toolchain.py2_runtime and toolchain.py2_runtime.interpreter_path:
41+
vars["PYTHON2"] = toolchain.py2_runtime.interpreter_path
42+
vars["PYTHON2_ROOTPATH"] = toolchain.py2_runtime.interpreter_path
3743

3844
files = depset(direct, transitive = transitive)
3945
return [

0 commit comments

Comments
 (0)