Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal(pystar): Only respect RULES_PYTHON_ENABLE_PYSTAR env var for Bazel 7+ #1698

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions python/private/internal_config_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,20 @@ bzl_library(
"""

def _internal_config_repo_impl(rctx):
enable_pystar = _bool_from_environ(rctx, _ENABLE_PYSTAR_ENVVAR_NAME, _ENABLE_PYSTAR_DEFAULT)
pystar_requested = _bool_from_environ(rctx, _ENABLE_PYSTAR_ENVVAR_NAME, _ENABLE_PYSTAR_DEFAULT)

# Bazel 7+ (dev and later) has native.starlark_doc_extract, and thus the
# py_internal global, which are necessary for the pystar implementation.
if pystar_requested and hasattr(native, "starlark_doc_extract"):
enable_pystar = pystar_requested
else:
enable_pystar = False

rctx.file("rules_python_config.bzl", _CONFIG_TEMPLATE.format(
enable_pystar = enable_pystar,
))

if enable_pystar or (
# Bazel 7+ (dev and later) has native.starlark_doc_extract, and thus the py_internal global
hasattr(native, "starlark_doc_extract") and
# The logic to allow the symbol doesn't work properly under bzlmod,
# even if the symbol is otherwise functional.
not BZLMOD_ENABLED
):
if enable_pystar:
shim_content = _PY_INTERNAL_SHIM
py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"'
else:
Expand Down