Skip to content

Commit 7b99ff7

Browse files
committed
fixup tests
1 parent bcb2310 commit 7b99ff7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

python/private/common.bzl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,18 @@ def create_py_info(
420420
py_info.merge_has_py2_only_sources(ctx.attr.srcs_version in ("PY2", "PY2ONLY"))
421421
py_info.merge_has_py3_only_sources(ctx.attr.srcs_version in ("PY3", "PY3ONLY"))
422422

423-
# First merge the third party deps
424-
# TODO @aignas 2025-06-05: refactor the code
423+
# First merge the third party deps so that the depsets get merged in a way to allow
424+
# topological traversal so that the first dependency that is met during traversing
425+
# will be a third party dep.
426+
#
427+
# This is because the DAG is going from first-party deps to third-party deps and usually
428+
# no third-party deps include first-party deps.
425429

430+
# TODO @aignas 2025-06-05: refactor the code
426431
for target in ctx.attr.deps:
427432
# PyInfo may not be present e.g. cc_library rules.
428433
if PyInfo in target or (BuiltinPyInfo != None and BuiltinPyInfo in target):
429-
if not target[PyInfo].package:
434+
if PyInfo in target and not target[PyInfo].package:
430435
continue
431436

432437
py_info.merge(_get_py_info(target))
@@ -441,7 +446,7 @@ def create_py_info(
441446
for target in ctx.attr.pyi_deps:
442447
# PyInfo may not be present e.g. cc_library rules.
443448
if PyInfo in target or (BuiltinPyInfo != None and BuiltinPyInfo in target):
444-
if not target[PyInfo].package:
449+
if PyInfo in target and not target[PyInfo].package:
445450
continue
446451

447452
py_info.merge(_get_py_info(target))
@@ -451,7 +456,9 @@ def create_py_info(
451456
for target in ctx.attr.deps:
452457
# PyInfo may not be present e.g. cc_library rules.
453458
if PyInfo in target or (BuiltinPyInfo != None and BuiltinPyInfo in target):
454-
if target[PyInfo].package:
459+
if PyInfo in target and target[PyInfo].package:
460+
continue
461+
elif PyInfo not in target:
455462
continue
456463

457464
py_info.merge(_get_py_info(target))
@@ -466,7 +473,9 @@ def create_py_info(
466473
for target in ctx.attr.pyi_deps:
467474
# PyInfo may not be present e.g. cc_library rules.
468475
if PyInfo in target or (BuiltinPyInfo != None and BuiltinPyInfo in target):
469-
if target[PyInfo].package:
476+
if PyInfo in target and target[PyInfo].package:
477+
continue
478+
elif PyInfo not in target:
470479
continue
471480

472481
py_info.merge(_get_py_info(target))

0 commit comments

Comments
 (0)