Skip to content

Commit 852da78

Browse files
committed
fix cases where builtin py info is none
1 parent 12a465b commit 852da78

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

python/private/common/py_executable.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,8 @@ def _create_providers(
890890
)
891891

892892
providers.append(py_info)
893-
providers.append(builtin_py_info)
893+
if builtin_py_info:
894+
providers.append(builtin_py_info)
894895
providers.append(create_output_group_info(py_info.transitive_sources, output_groups))
895896

896897
extra_providers = semantics.get_extra_providers(

python/private/common/py_library.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,16 @@ def py_library_impl(ctx, *, semantics):
9898
dependency_transitive_python_sources = deps_transitive_sources,
9999
)
100100

101-
return [
101+
providers = [
102102
DefaultInfo(files = default_outputs, runfiles = runfiles),
103103
py_info,
104-
builtins_py_info,
105104
create_instrumented_files_info(ctx),
106105
PyCcLinkParamsProvider(cc_info = cc_info),
107106
create_output_group_info(py_info.transitive_sources, extra_groups = {}),
108107
]
108+
if builtins_py_info:
109+
providers.append(builtins_py_info)
110+
return providers
109111

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

python/private/py_info.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ def _PyInfoBuilder_build(self):
229229
)
230230

231231
def _PyInfoBuilder_build_builtin_py_info(self):
232+
if BuiltinPyInfo == None:
233+
return None
234+
232235
return BuiltinPyInfo(
233236
has_py2_only_sources = self._has_py2_only_sources[0],
234237
has_py3_only_sources = self._has_py3_only_sources[0],

tests/base_rules/py_info/py_info_tests.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def _test_py_info_builder_impl(env, targets):
179179
])
180180

181181
check(builder.build())
182-
check(builder.build_builtin_py_info())
182+
if BuiltinPyInfo != None:
183+
check(builder.build_builtin_py_info())
183184

184185
builder.set_has_py2_only_sources(False)
185186
builder.set_has_py3_only_sources(False)

0 commit comments

Comments
 (0)