@@ -59,7 +59,7 @@ load(":py_cc_link_params_info.bzl", "PyCcLinkParamsInfo")
5959load (":py_executable_info.bzl" , "PyExecutableInfo" )
6060load (":py_info.bzl" , "PyInfo" , "VenvSymlinkKind" )
6161load (":py_internal.bzl" , "py_internal" )
62- load (":py_runtime_info.bzl" , "DEFAULT_STUB_SHEBANG" , "PyRuntimeInfo" )
62+ load (":py_runtime_info.bzl" , "DEFAULT_STUB_SHEBANG" )
6363load (":reexports.bzl" , "BuiltinPyInfo" , "BuiltinPyRuntimeInfo" )
6464load (":rule_builders.bzl" , "ruleb" )
6565load (":toolchain_types.bzl" , "EXEC_TOOLS_TOOLCHAIN_TYPE" , "TARGET_TOOLCHAIN_TYPE" , TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE" )
@@ -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,41 +1193,28 @@ 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
1238-
1239- return toolchain_runtime , effective_runtime
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+ return py3_runtime , py3_runtime
12401218
12411219def _get_base_runfiles_for_binary (
12421220 ctx ,
0 commit comments