Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ END_UNRELEASED_TEMPLATE
paths, runtime site-packages]`.
* (pip) Publishing deps are no longer pulled via `experimental_index_url`.
([#2937](https://github.com/bazel-contrib/rules_python/issues/2937)).
* (toolchains) `py_runtime` and `PyRuntimeInfo` reject Python 2 settings.
Setting `py_runtime.python_version = "PY2"` or non-None
`PyRuntimeInfo.py2_runtime` is an error.

{#v0-0-0-fixed}
### Fixed
Expand Down
1 change: 0 additions & 1 deletion python/private/flags.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ load(":enum.bzl", "FlagEnum", "enum")
_POSSIBLY_NATIVE_FLAGS = {
"build_python_zip": (lambda ctx: ctx.fragments.py.build_python_zip, "native"),
"default_to_explicit_init_py": (lambda ctx: ctx.fragments.py.default_to_explicit_init_py, "native"),
"disable_py2": (lambda ctx: ctx.fragments.py.disable_py2, "native"),
"python_import_all_repositories": (lambda ctx: ctx.fragments.bazel_py.python_import_all_repositories, "native"),
"python_path": (lambda ctx: ctx.fragments.bazel_py.python_path, "native"),
}
Expand Down
17 changes: 3 additions & 14 deletions python/private/py_runtime_pair_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("//python:py_runtime_info.bzl", "PyRuntimeInfo")
load(":common_labels.bzl", "labels")
load(":flags.bzl", "read_possibly_native_flag")
load(":reexports.bzl", "BuiltinPyRuntimeInfo")

def _py_runtime_pair_impl(ctx):
Expand All @@ -37,10 +36,9 @@ def _py_runtime_pair_impl(ctx):
else:
py3_runtime = None

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

extra_kwargs = {}
if ctx.attr._visible_for_testing[BuildSettingInfo].value:
Expand All @@ -62,15 +60,6 @@ def _get_py_runtime_info(target):
else:
return target[BuiltinPyRuntimeInfo]

# buildifier: disable=unused-variable
def _is_py2_disabled(ctx):
# Because this file isn't bundled with Bazel, so we have to conditionally
# check for this flag.
# TODO: Remove this once all supported Balze versions have this flag.
if not hasattr(ctx.fragments.py, "disable_py"):
return False
return read_possibly_native_flag(ctx, "disable_py2")

_MaybeBuiltinPyRuntimeInfo = [[BuiltinPyRuntimeInfo]] if BuiltinPyRuntimeInfo != None else []

py_runtime_pair = rule(
Expand Down
7 changes: 3 additions & 4 deletions python/private/py_runtime_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ def _py_runtime_impl(ctx):
if python_version_flag:
interpreter_version_info = _interpreter_version_info_from_version_str(python_version_flag)

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

pyc_tag = ctx.attr.pyc_tag
if not pyc_tag and (ctx.attr.implementation_name and
Expand Down