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

chore: various cleanups to make google imports/patching easier #1958

Merged
merged 1 commit into from
Jun 14, 2024
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
10 changes: 5 additions & 5 deletions python/config_settings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,39 @@ string_flag(
name = "precompile",
build_setting_default = PrecompileFlag.AUTO,
values = sorted(PrecompileFlag.__members__.values()),
# NOTE: Only public because its an implicit dependency
# NOTE: Only public because it's an implicit dependency
visibility = ["//visibility:public"],
)

string_flag(
name = "precompile_source_retention",
build_setting_default = PrecompileSourceRetentionFlag.KEEP_SOURCE,
values = sorted(PrecompileSourceRetentionFlag.__members__.values()),
# NOTE: Only public because its an implicit dependency
# NOTE: Only public because it's an implicit dependency
visibility = ["//visibility:public"],
)

string_flag(
name = "precompile_add_to_runfiles",
build_setting_default = PrecompileAddToRunfilesFlag.ALWAYS,
values = sorted(PrecompileAddToRunfilesFlag.__members__.values()),
# NOTE: Only public because its an implicit dependency
# NOTE: Only public because it's an implicit dependency
visibility = ["//visibility:public"],
)

string_flag(
name = "pyc_collection",
build_setting_default = PycCollectionFlag.DISABLED,
values = sorted(PycCollectionFlag.__members__.values()),
# NOTE: Only public because its an implicit dependency
# NOTE: Only public because it's an implicit dependency
visibility = ["//visibility:public"],
)

string_flag(
name = "bootstrap_impl",
build_setting_default = BootstrapImplFlag.SYSTEM_PYTHON,
values = sorted(BootstrapImplFlag.__members__.values()),
# NOTE: Only public because its an implicit dependency
# NOTE: Only public because it's an implicit dependency
visibility = ["//visibility:public"],
)

Expand Down
1 change: 1 addition & 0 deletions python/private/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bzl_library(
"//python/private:enum_bzl",
"//python/private:flags_bzl",
"//python/private:reexports_bzl",
"//python/private:rules_cc_srcs_bzl",
"@bazel_skylib//rules:common_settings",
],
)
Expand Down
26 changes: 15 additions & 11 deletions python/private/common/py_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ def py_library_impl(ctx, *, semantics):
create_output_group_info(py_info.transitive_sources, extra_groups = {}),
]

_DEFAULT_PY_LIBRARY_DOC = """
A library of Python code that can be depended upon.

Default outputs:
* The input Python sources
* The precompiled artifacts from the sources.

NOTE: Precompilation affects which of the default outputs are included in the
resulting runfiles. See the precompile-related attributes and flags for
more information.
"""

def create_py_library_rule(*, attrs = {}, **kwargs):
"""Creates a py_library rule.

Expand All @@ -111,6 +123,9 @@ def create_py_library_rule(*, attrs = {}, **kwargs):
Returns:
A rule object
"""

# Within Google, the doc attribute is overridden
kwargs.setdefault("doc", _DEFAULT_PY_LIBRARY_DOC)
return rule(
attrs = dicts.add(LIBRARY_ATTRS, attrs),
toolchains = [
Expand All @@ -120,16 +135,5 @@ def create_py_library_rule(*, attrs = {}, **kwargs):
# TODO(b/253818097): fragments=py is only necessary so that
# RequiredConfigFragmentsTest passes
fragments = ["py"],
doc = """
A library of Python code that can be depended upon.

Default outputs:
* The input Python sources
* The precompiled artifacts from the sources.

NOTE: Precompilation affects which of the default outputs are included in the
resulting runfiles. See the precompile-related attributes and flags for
more information.
""",
**kwargs
)
Loading