Skip to content

Commit 8159fb3

Browse files
committed
remove usages of py.disable_py2
1 parent 309e93e commit 8159fb3

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

python/private/flags.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ load(":enum.bzl", "FlagEnum", "enum")
3939
_POSSIBLY_NATIVE_FLAGS = {
4040
"build_python_zip": (lambda ctx: ctx.fragments.py.build_python_zip, "native"),
4141
"default_to_explicit_init_py": (lambda ctx: ctx.fragments.py.default_to_explicit_init_py, "native"),
42-
"disable_py2": (lambda ctx: ctx.fragments.py.disable_py2, "native"),
4342
"python_import_all_repositories": (lambda ctx: ctx.fragments.bazel_py.python_import_all_repositories, "native"),
4443
"python_path": (lambda ctx: ctx.fragments.bazel_py.python_path, "native"),
4544
}

python/private/py_runtime_pair_rule.bzl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def _py_runtime_pair_impl(ctx):
3737
else:
3838
py3_runtime = None
3939

40-
# TODO: Uncomment this after --incompatible_python_disable_py2 defaults to true
41-
# if _is_py2_disabled(ctx) and py2_runtime != None:
42-
# fail("Using Python 2 is not supported and disabled; see " +
43-
# "https://github.com/bazelbuild/bazel/issues/15684")
40+
41+
if py2_runtime != None:
42+
fail("Using Python 2 is not supported and disabled; see " +
43+
"https://github.com/bazelbuild/bazel/issues/15684")
4444

4545
extra_kwargs = {}
4646
if ctx.attr._visible_for_testing[BuildSettingInfo].value:
@@ -62,15 +62,6 @@ def _get_py_runtime_info(target):
6262
else:
6363
return target[BuiltinPyRuntimeInfo]
6464

65-
# buildifier: disable=unused-variable
66-
def _is_py2_disabled(ctx):
67-
# Because this file isn't bundled with Bazel, so we have to conditionally
68-
# check for this flag.
69-
# TODO: Remove this once all supported Balze versions have this flag.
70-
if not hasattr(ctx.fragments.py, "disable_py"):
71-
return False
72-
return read_possibly_native_flag(ctx, "disable_py2")
73-
7465
_MaybeBuiltinPyRuntimeInfo = [[BuiltinPyRuntimeInfo]] if BuiltinPyRuntimeInfo != None else []
7566

7667
py_runtime_pair = rule(

python/private/py_runtime_rule.bzl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ def _py_runtime_impl(ctx):
8787
if python_version_flag:
8888
interpreter_version_info = _interpreter_version_info_from_version_str(python_version_flag)
8989

90-
# TODO: Uncomment this after --incompatible_python_disable_py2 defaults to true
91-
# if ctx.fragments.py.disable_py2 and python_version == "PY2":
92-
# fail("Using Python 2 is not supported and disabled; see " +
93-
# "https://github.com/bazelbuild/bazel/issues/15684")
90+
if python_version == "PY2":
91+
fail("Using Python 2 is not supported and disabled; see " +
92+
"https://github.com/bazelbuild/bazel/issues/15684")
9493

9594
pyc_tag = ctx.attr.pyc_tag
9695
if not pyc_tag and (ctx.attr.implementation_name and

0 commit comments

Comments
 (0)