Skip to content

Commit 2081232

Browse files
committed
docs
1 parent 6cfa441 commit 2081232

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

python/private/attributes.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ The order of this list can matter because it affects the order that information
260260
from dependencies is merged in, which can be relevant depending on the ordering
261261
mode of depsets that are merged.
262262
263-
* {obj}`PyInfo.venv_symlinks` uses topological ordering.
263+
* {obj}`PyInfo.venv_symlinks` uses default ordering.
264264
265265
See {obj}`PyInfo` for more information about the ordering of its depsets and
266266
how its fields are merged.

python/private/common.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ def _third_party_first(targets):
373373
"""Sort targets to allow for deterministic depset merging.
374374
375375
First return the third party deps so that the depsets get merged in a way to allow
376-
topological traversal so that the first dependency that is met during traversing
377-
will be a third party dep.
376+
traversal so that the first dependency that is met during traversing will be a third party
377+
dep.
378378
379379
This is because the DAG is going from first-party deps to third-party deps and usually
380380
no third-party deps include first-party deps.

python/private/py_executable.bzl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,6 @@ def _create_venv_symlinks(ctx, venv_dir_map):
650650

651651
# maps venv-relative path to the runfiles path it should point to
652652
entries = depset(
653-
# NOTE: Topological ordering is used so that dependencies closer to the
654-
# binary have precedence in creating their symlinks. This allows the
655-
# binary a modicum of control over the result.
656-
order = "topological",
657653
transitive = [
658654
dep[PyInfo].venv_symlinks
659655
for dep in ctx.attr.deps
@@ -692,7 +688,8 @@ def _build_link_map(entries):
692688

693689
if version_by_pkg.setdefault(entry.package, entry.version) != entry.version:
694690
# We ignore duplicates by design. The dependency closer to the
695-
# binary gets precedence due to the topological ordering.
691+
# binary gets precedence due to how we merge the third_party dependencies
692+
# first.
696693
continue
697694
elif entry.venv_path in kind_map:
698695
# NOTE @aignas 2025-06-05: This branch should be hit only for first party
@@ -701,9 +698,9 @@ def _build_link_map(entries):
701698
else:
702699
kind_map[entry.venv_path] = entry.link_to_path
703700

704-
# An empty link_to value means to not create the site package symlink.
705-
# Because of the topological ordering, this allows binaries to remove
706-
# entries by having an earlier dependency produce empty link_to values.
701+
# An empty link_to value means to not create the site package symlink. Because of the
702+
# ordering, this allows binaries to remove entries by having an earlier dependency produce
703+
# empty link_to values.
707704
for link_map in pkg_link_map.values():
708705
for kind, kind_map in link_map.items():
709706
for dir_path, link_to in kind_map.items():

python/private/py_info.bzl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _PyInfo_init(
115115
transitive_original_sources = depset(),
116116
direct_pyi_files = depset(),
117117
transitive_pyi_files = depset(),
118-
venv_symlinks = depset(order = "topological")):
118+
venv_symlinks = depset()):
119119
_check_arg_type("transitive_sources", "depset", transitive_sources)
120120

121121
# Verify it's postorder compatible, but retain is original ordering.
@@ -220,7 +220,15 @@ Python targets. These are accumulated from the transitive `deps`.
220220
The order of the depset is not guaranteed and may be changed in the future. It
221221
is recommended to use `default` order (the default).
222222
""",
223-
"package": "TODO",
223+
"package": """
224+
:type: str
225+
226+
The source third-party dependency name, which is normalized to PEP440 schema with
227+
`-` replaced with `_`.
228+
229+
::::{versionadded} VERSION_NEXT_FEATURE
230+
::::
231+
""",
224232
"transitive_implicit_pyc_files": """
225233
:type: depset[File]
226234
@@ -312,13 +320,13 @@ This field is currently unused in Bazel and may go away in the future.
312320
"venv_symlinks": """
313321
:type: depset[VenvSymlinkEntry]
314322
315-
A depset with `topological` ordering.
323+
A depset with default ordering.
316324
317325
:::{include} /_includes/experimental_api.md
318326
:::
319327
320328
:::{tip}
321-
The topological ordering means dependencies earlier and closer to the consumer
329+
The way we merge depsets means dependencies earlier and closer to the consumer
322330
have precedence. This allows e.g. a binary to add dependencies that override
323331
values from further way dependencies, such as forcing symlinks to point to
324332
specific paths or preventing symlinks from being created.
@@ -380,9 +388,6 @@ def _PyInfoBuilder_typedef():
380388
381389
:::{field} venv_symlinks
382390
:type: DepsetBuilder[tuple[str | None, str]]
383-
384-
NOTE: This depset has `topological` order
385-
:::
386391
"""
387392

388393
def _PyInfoBuilder_new():
@@ -422,7 +427,7 @@ def _PyInfoBuilder_new():
422427
transitive_pyc_files = builders.DepsetBuilder(),
423428
transitive_pyi_files = builders.DepsetBuilder(),
424429
transitive_sources = builders.DepsetBuilder(),
425-
venv_symlinks = builders.DepsetBuilder(order = "topological"),
430+
venv_symlinks = builders.DepsetBuilder(),
426431
)
427432
return self
428433

python/private/py_library.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,18 @@ won't be understood as namespace packages; they'll be seen as regular packages.
9292
likely lead to conflicts with other targets that contribute to the namespace.
9393
9494
:::{tip}
95-
This attributes populates {obj}`PyInfo.venv_symlinks`, which is
96-
a topologically ordered depset. This means dependencies closer and earlier
95+
This attributes populates {obj}`PyInfo.venv_symlinks` a custom ordered depset - third party dependencies come first when the depsets are merged. This means dependencies closer and earlier
9796
to a consumer have precedence. See {obj}`PyInfo.venv_symlinks` for
9897
more information.
9998
:::
10099
101100
:::{versionadded} 1.4.0
102101
:::
102+
:::{versionchanged} VERSION_NEXT_FEATURE
103+
The topological order has been reverted and instead we merge the depsets for all of the
104+
targets in the {attr}`py_library.deps` in a particular way - first merging depsets
105+
of the third-party PyPI dependencies and then merging the first-party dependencies.
106+
:::
103107
""",
104108
),
105109
"_add_srcs_to_runfiles_flag": lambda: attrb.Label(

0 commit comments

Comments
 (0)