Skip to content

Commit

Permalink
python: Remove Google-code path for flag-based interpreter path.
Browse files Browse the repository at this point in the history
This only affects the Google build; the Bazel `--python_path` flag is still
implemented.

PiperOrigin-RevId: 505757395
Change-Id: I019afa973a67b2e74bfd7c73ddc8c7c96e9d29e8
  • Loading branch information
rickeylev authored and copybara-github committed Jan 30, 2023
1 parent b2d47a0 commit 8e41dce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
18 changes: 5 additions & 13 deletions src/main/starlark/builtins_bzl/common/python/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -227,26 +225,20 @@ 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
toolchain_runtime = None
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
Expand Down
2 changes: 0 additions & 2 deletions src/main/starlark/builtins_bzl/common/python/semantics.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8e41dce

Please sign in to comment.