@@ -1153,22 +1153,13 @@ def _get_runtime_details(ctx):
11531153
11541154 # Bazel has --python_path. This flag has a computed default of "python" when
11551155 # its actual default is null (see
1156- # BazelPythonConfiguration.java#getPythonPath). This flag is only used if
1157- # toolchains are not enabled and `--python_top` isn't set. Note that Google
1158- # used to have a variant of this named --python_binary, but it has since
1159- # been removed.
1160- #
11611156 # TOOD(bazelbuild/bazel#7901): Remove this once --python_path flag is removed.
11621157
11631158 flag_interpreter_path = read_possibly_native_flag (ctx , "python_path" )
11641159 if not flag_interpreter_path .startswith ("python" ) and not paths .is_absolute (flag_interpreter_path ):
11651160 fail ("'python_path' must be an absolute path or a name to be resolved from the system PATH (e.g., 'python', 'python3')." )
11661161
1167- toolchain_runtime , effective_runtime = _maybe_get_runtime_from_ctx (ctx )
1168- if not effective_runtime :
1169- # Clear these just in case
1170- toolchain_runtime = None
1171- effective_runtime = None
1162+ effective_runtime = _maybe_get_runtime_from_ctx (ctx )
11721163
11731164 if effective_runtime :
11741165 direct = [] # List of files
@@ -1193,16 +1184,9 @@ def _get_runtime_details(ctx):
11931184 )
11941185
11951186 return struct (
1196- # Optional PyRuntimeInfo: The runtime found from toolchain resolution.
1197- # This may be None because, within Google, toolchain resolution isn't
1198- # yet enabled.
1199- toolchain_runtime = toolchain_runtime ,
1200- # Optional PyRuntimeInfo: The runtime that should be used. When
1201- # toolchain resolution is enabled, this is the same as
1202- # `toolchain_resolution`. Otherwise, this probably came from the
1203- # `_python_top` attribute that the Google implementation still uses.
1204- # This is separate from `toolchain_runtime` because toolchain_runtime
1205- # is propagated as a provider, while non-toolchain runtimes are not.
1187+ # Optional PyRuntimeInfo: The runtime that should be used.
1188+ # If None, it's probably Windows using the legacy auto-detecting toolchain
1189+ # that acts as if no toolchain was found.
12061190 effective_runtime = effective_runtime ,
12071191 # str; Path to the Python interpreter to use for running the executable
12081192 # itself (not the bootstrap script). Either an absolute path (which
@@ -1219,7 +1203,7 @@ def _maybe_get_runtime_from_ctx(ctx):
12191203 """Finds the PyRuntimeInfo from the toolchain or attribute, if available.
12201204
12211205 Returns:
1222- 2-tuple of toolchain_runtime, effective_runtime
1206+ A PyRuntimeInfo provider, or None.
12231207 """
12241208 toolchain = ctx .toolchains [TOOLCHAIN_TYPE ]
12251209
@@ -1236,13 +1220,13 @@ def _maybe_get_runtime_from_ctx(ctx):
12361220 # TODO(#7844): Remove this hack when the autodetecting toolchain has a
12371221 # Windows implementation.
12381222 if py3_runtime .interpreter_path == "/_magic_pyruntime_sentinel_do_not_use" :
1239- return None , None
1223+ return None
12401224
12411225 if py3_runtime .python_version != "PY3" :
12421226 fail ("Python toolchain py3_runtime must be python_version=PY3, got {}" .format (
12431227 py3_runtime .python_version ,
12441228 ))
1245- return py3_runtime , py3_runtime
1229+ return py3_runtime
12461230
12471231def _get_base_runfiles_for_binary (
12481232 ctx ,
@@ -1701,10 +1685,10 @@ def _create_providers(
17011685 ),
17021686 ]
17031687
1704- # TODO(b/265840007): Make this non-conditional once Google enables
1705- # --incompatible_use_python_toolchains .
1706- if runtime_details .toolchain_runtime :
1707- py_runtime_info = runtime_details .toolchain_runtime
1688+ # TODO - The effective runtime can be None for Windows + auto detecting toolchain.
1689+ # This can be removed once that's fixed; see maybe_get_runtime_from_ctx() .
1690+ if runtime_details .effective_runtime :
1691+ py_runtime_info = runtime_details .effective_runtime
17081692 providers .append (py_runtime_info )
17091693
17101694 # Re-add the builtin PyRuntimeInfo for compatibility to make
0 commit comments