Skip to content

chore: remove semantics.bzl #2725

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

Merged
merged 2 commits into from
Apr 1, 2025
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
9 changes: 0 additions & 9 deletions python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ bzl_library(
":py_internal_bzl",
":reexports_bzl",
":rules_cc_srcs_bzl",
":semantics_bzl",
"@bazel_skylib//rules:common_settings",
],
)
Expand Down Expand Up @@ -131,7 +130,6 @@ bzl_library(
":py_internal_bzl",
":reexports_bzl",
":rules_cc_srcs_bzl",
":semantics_bzl",
"@bazel_skylib//lib:paths",
],
)
Expand Down Expand Up @@ -302,7 +300,6 @@ bzl_library(
":attributes_bzl",
":py_executable_bzl",
":rule_builders_bzl",
":semantics_bzl",
"@bazel_skylib//lib:dicts",
],
)
Expand Down Expand Up @@ -537,7 +534,6 @@ bzl_library(
":common_bzl",
":py_executable_bzl",
":rule_builders_bzl",
":semantics_bzl",
"@bazel_skylib//lib:dicts",
],
)
Expand Down Expand Up @@ -677,11 +673,6 @@ bzl_library(
],
)

bzl_library(
name = "semantics_bzl",
srcs = ["semantics.bzl"],
)

# Needed to define bzl_library targets for docgen. (We don't define the
# bzl_library target here because it'd give our users a transitive dependency
# on Skylib.)
Expand Down
11 changes: 1 addition & 10 deletions python/private/attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ load(":py_info.bzl", "PyInfo")
load(":py_internal.bzl", "py_internal")
load(":reexports.bzl", "BuiltinPyInfo")
load(":rule_builders.bzl", "ruleb")
load(
":semantics.bzl",
"DEPS_ATTR_ALLOW_RULES",
"SRCS_ATTR_ALLOW_FILES",
)

_PackageSpecificationInfo = getattr(py_internal, "PackageSpecificationInfo", None)

Expand Down Expand Up @@ -250,9 +245,6 @@ PY_SRCS_ATTRS = dicts.add(
[PyInfo],
[CcInfo],
] + _MaybeBuiltinPyInfo,
# TODO(b/228692666): Google-specific; remove these allowances once
# the depot is cleaned up.
allow_rules = DEPS_ATTR_ALLOW_RULES,
doc = """
List of additional libraries to be linked in to the target.
See comments about
Expand Down Expand Up @@ -359,8 +351,7 @@ as part of a runnable program (packaging rules may include them, however).
allow_files = True,
),
"srcs": lambda: attrb.LabelList(
# Google builds change the set of allowed files.
allow_files = SRCS_ATTR_ALLOW_FILES,
allow_files = [".py", ".py3"],
# Necessary for --compile_one_dependency to work.
flags = ["DIRECT_COMPILE_TIME_INPUT"],
doc = """
Expand Down
36 changes: 11 additions & 25 deletions python/private/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ load(":py_internal.bzl", "py_internal")
load(":py_runtime_info.bzl", "DEFAULT_STUB_SHEBANG", "PyRuntimeInfo")
load(":reexports.bzl", "BuiltinPyInfo", "BuiltinPyRuntimeInfo")
load(":rule_builders.bzl", "ruleb")
load(
":semantics.bzl",
"ALLOWED_MAIN_EXTENSIONS",
"BUILD_DATA_SYMLINK_PATH",
"IS_BAZEL",
"PY_RUNTIME_ATTR_NAME",
)
load(
":toolchain_types.bzl",
"EXEC_TOOLS_TOOLCHAIN_TYPE",
Expand Down Expand Up @@ -1116,19 +1109,12 @@ def _get_runtime_details(ctx, semantics):
#
# TOOD(bazelbuild/bazel#7901): Remove this once --python_path flag is removed.

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
flag_interpreter_path = None
toolchain_runtime, effective_runtime = _maybe_get_runtime_from_ctx(ctx)
if not effective_runtime:
fail("Unable to find Python runtime")
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

if effective_runtime:
direct = [] # List of files
Expand Down Expand Up @@ -1207,7 +1193,7 @@ def _maybe_get_runtime_from_ctx(ctx):
effective_runtime = toolchain_runtime
else:
toolchain_runtime = None
attr_target = getattr(ctx.attr, PY_RUNTIME_ATTR_NAME)
attr_target = ctx.attr._py_interpreter

# In Bazel, --python_top is null by default.
if attr_target and PyRuntimeInfo in attr_target:
Expand Down Expand Up @@ -1335,9 +1321,9 @@ def _create_runfiles_with_build_data(
central_uncachable_version_file,
extra_write_build_data_env,
)
build_data_runfiles = ctx.runfiles(symlinks = {
BUILD_DATA_SYMLINK_PATH: build_data_file,
})
build_data_runfiles = ctx.runfiles(files = [
build_data_file,
])
return build_data_file, build_data_runfiles

def _write_build_data(ctx, central_uncachable_version_file, extra_write_build_data_env):
Expand Down Expand Up @@ -1552,7 +1538,7 @@ def determine_main(ctx):
"""
if ctx.attr.main:
proposed_main = ctx.attr.main.label.name
if not proposed_main.endswith(tuple(ALLOWED_MAIN_EXTENSIONS)):
if not proposed_main.endswith(".py"):
fail("main must end in '.py'")
else:
if ctx.label.name.endswith(".py"):
Expand Down
31 changes: 0 additions & 31 deletions python/private/semantics.bzl

This file was deleted.