From 8e41dce65b97a3d466d6b1e65005abc52a07b90b Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 30 Jan 2023 11:51:50 -0800 Subject: [PATCH] python: Remove Google-code path for flag-based interpreter path. This only affects the Google build; the Bazel `--python_path` flag is still implemented. PiperOrigin-RevId: 505757395 Change-Id: I019afa973a67b2e74bfd7c73ddc8c7c96e9d29e8 --- .../common/python/py_executable.bzl | 18 +++++------------- .../builtins_bzl/common/python/semantics.bzl | 2 -- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/main/starlark/builtins_bzl/common/python/py_executable.bzl b/src/main/starlark/builtins_bzl/common/python/py_executable.bzl index 48ee8b365542b6..714e028c2cbd2b 100644 --- a/src/main/starlark/builtins_bzl/common/python/py_executable.bzl +++ b/src/main/starlark/builtins_bzl/common/python/py_executable.bzl @@ -45,8 +45,6 @@ load( "BUILD_DATA_SYMLINK_PATH", "IS_BAZEL", "PY_RUNTIME_ATTR_NAME", - "PY_RUNTIME_FRAGMENT_ATTR_NAME", - "PY_RUNTIME_FRAGMENT_NAME", ) _cc_common = _builtins.toplevel.cc_common @@ -227,10 +225,9 @@ def _get_runtime_details(ctx, semantics): # # TODO(b/230428071): Remove this once Google's --python_binary flag is removed. # TOOD(bazelbuild/bazel#7901): Remove this once --python_path flag is removed. - fragment = getattr(ctx.fragments, PY_RUNTIME_FRAGMENT_NAME) - flag_interpreter_path = getattr(fragment, PY_RUNTIME_FRAGMENT_ATTR_NAME) if IS_BAZEL: + flag_interpreter_path = ctx.fragments.bazel_py.python_path toolchain_runtime, effective_runtime = _maybe_get_runtime_from_ctx(ctx) if not effective_runtime: # Clear these just in case @@ -238,15 +235,10 @@ def _get_runtime_details(ctx, semantics): effective_runtime = None else: # Google code path - # TODO(b/230428071): This codepath can go away once Google's - # --python_binary flag is removed. - if flag_interpreter_path: - toolchain_runtime = None - effective_runtime = None - else: - toolchain_runtime, effective_runtime = _maybe_get_runtime_from_ctx(ctx) - if not effective_runtime: - fail("should have found runtime") + flag_interpreter_path = None + toolchain_runtime, effective_runtime = _maybe_get_runtime_from_ctx(ctx) + if not effective_runtime: + fail("Unable to find Python runtime") if effective_runtime: direct = [] # List of files diff --git a/src/main/starlark/builtins_bzl/common/python/semantics.bzl b/src/main/starlark/builtins_bzl/common/python/semantics.bzl index 3b60b78607781b..6af9ac73bbd36f 100644 --- a/src/main/starlark/builtins_bzl/common/python/semantics.bzl +++ b/src/main/starlark/builtins_bzl/common/python/semantics.bzl @@ -23,8 +23,6 @@ SRCS_ATTR_ALLOW_FILES = [".py", ".py3"] DEPS_ATTR_ALLOW_RULES = None PY_RUNTIME_ATTR_NAME = "_py_interpreter" -PY_RUNTIME_FRAGMENT_NAME = "bazel_py" -PY_RUNTIME_FRAGMENT_ATTR_NAME = "python_path" BUILD_DATA_SYMLINK_PATH = None