@@ -203,15 +203,6 @@ accepting arbitrary Python versions.
203203 # empty target for other platforms.
204204 default = "//tools/launcher:launcher" ,
205205 ),
206- "_py_interpreter" : lambda : attrb .Label (
207- # The configuration_field args are validated when called;
208- # we use the precense of py_internal to indicate this Bazel
209- # build has that fragment and name.
210- default = configuration_field (
211- fragment = "bazel_py" ,
212- name = "python_top" ,
213- ) if py_internal else None ,
214- ),
215206 # TODO: This appears to be vestigial. It's only added because
216207 # GraphlessQueryTest.testLabelsOperator relies on it to test for
217208 # query behavior of implicit dependencies.
@@ -1202,39 +1193,29 @@ def _maybe_get_runtime_from_ctx(ctx):
12021193 Returns:
12031194 2-tuple of toolchain_runtime, effective_runtime
12041195 """
1205- if ctx .fragments .py .use_toolchains :
1206- toolchain = ctx .toolchains [TOOLCHAIN_TYPE ]
1207-
1208- if not hasattr (toolchain , "py3_runtime" ):
1209- fail ("Python toolchain field 'py3_runtime' is missing" )
1210- if not toolchain .py3_runtime :
1211- fail ("Python toolchain missing py3_runtime" )
1212- py3_runtime = toolchain .py3_runtime
1213-
1214- # Hack around the fact that the autodetecting Python toolchain, which is
1215- # automatically registered, does not yet support Windows. In this case,
1216- # we want to return null so that _get_interpreter_path falls back on
1217- # --python_path. See tools/python/toolchain.bzl.
1218- # TODO(#7844): Remove this hack when the autodetecting toolchain has a
1219- # Windows implementation.
1220- if py3_runtime .interpreter_path == "/_magic_pyruntime_sentinel_do_not_use" :
1221- return None , None
1222-
1223- if py3_runtime .python_version != "PY3" :
1224- fail ("Python toolchain py3_runtime must be python_version=PY3, got {}" .format (
1225- py3_runtime .python_version ,
1226- ))
1227- toolchain_runtime = toolchain .py3_runtime
1228- effective_runtime = toolchain_runtime
1229- else :
1230- toolchain_runtime = None
1231- attr_target = ctx .attr ._py_interpreter
1232-
1233- # In Bazel, --python_top is null by default.
1234- if attr_target and PyRuntimeInfo in attr_target :
1235- effective_runtime = attr_target [PyRuntimeInfo ]
1236- else :
1237- return None , None
1196+ toolchain = ctx .toolchains [TOOLCHAIN_TYPE ]
1197+
1198+ if not hasattr (toolchain , "py3_runtime" ):
1199+ fail ("Python toolchain field 'py3_runtime' is missing" )
1200+ if not toolchain .py3_runtime :
1201+ fail ("Python toolchain missing py3_runtime" )
1202+ py3_runtime = toolchain .py3_runtime
1203+
1204+ # Hack around the fact that the autodetecting Python toolchain, which is
1205+ # automatically registered, does not yet support Windows. In this case,
1206+ # we want to return null so that _get_interpreter_path falls back on
1207+ # --python_path. See tools/python/toolchain.bzl.
1208+ # TODO(#7844): Remove this hack when the autodetecting toolchain has a
1209+ # Windows implementation.
1210+ if py3_runtime .interpreter_path == "/_magic_pyruntime_sentinel_do_not_use" :
1211+ return None , None
1212+
1213+ if py3_runtime .python_version != "PY3" :
1214+ fail ("Python toolchain py3_runtime must be python_version=PY3, got {}" .format (
1215+ py3_runtime .python_version ,
1216+ ))
1217+ toolchain_runtime = toolchain .py3_runtime
1218+ effective_runtime = toolchain_runtime
12381219
12391220 return toolchain_runtime , effective_runtime
12401221
0 commit comments