File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,22 @@ _POSSIBLY_NATIVE_FLAGS = {
4545 "use_toolchains" : (lambda ctx : ctx .fragments .py .use_toolchains , "native" ),
4646}
4747
48- # API for reading flags that might be defined in Starlark or in Bazel. All code
49- # that reads Python flags should read them through this function.
50- #
51- # This properly routes to the right flag source depending on Bazel version and
52- # the --incompatible* flags that disable native flag references.
5348def read_possibly_native_flag (ctx , flag_name ):
49+ """
50+ Canonical API for reading a Python build flag.
51+
52+ Flags might be defined in Starlark or native-Bazel. This function reasd flags
53+ from tbe correct source based on supporting Bazel version and --incompatible*
54+ flags that disable native references.
55+
56+ Args:
57+ ctx: Rule's configuration context.
58+ flag_name: Name of the flag to read, without preceding "--".
59+
60+ Returns:
61+ The flag's value.
62+ """
63+
5464 # Bazel 9.0+ can disable these fragments with --incompatible_remove_ctx_py_fragment and
5565 # --incompatible_remove_ctx_bazel_py_fragment. Disabling them means bazel expects
5666 # Python to read Starlark flags.
Original file line number Diff line number Diff line change 1717load ("@bazel_skylib//rules:common_settings.bzl" , "BuildSettingInfo" )
1818load ("//python:py_runtime_info.bzl" , "PyRuntimeInfo" )
1919load (":common_labels.bzl" , "labels" )
20+ load (":flags.bzl" , "read_possibly_native_flag" )
2021load (":reexports.bzl" , "BuiltinPyRuntimeInfo" )
2122load (":util.bzl" , "IS_BAZEL_7_OR_HIGHER" )
22- load (":flags.bzl" , "read_possibly_native_flag" )
2323
2424def _py_runtime_pair_impl (ctx ):
2525 if ctx .attr .py2_runtime != None :
You can’t perform that action at this time.
0 commit comments