Fix Bazel build output resolution under --symlink_prefix#67
Open
hartikainen wants to merge 5 commits into
Open
Fix Bazel build output resolution under --symlink_prefix#67hartikainen wants to merge 5 commits into
--symlink_prefix#67hartikainen wants to merge 5 commits into
Conversation
16dce0e to
9cde57d
Compare
`_build_multiple_targets` currently joints the workspace directory with each output's `path_prefix` (`bazel-out/...`), which only resolves through the default `bazel-out` convenience symlink. Under a non-default `--symlink_prefix` (e.g. `--symlink_prefix=.bazel/`) that symlink doesn't exist, so the returned paths point nowhere and packaging fails. This commit refactors the resolution to prefer `file://` URI that Bazel emits in the BEP `File` messages. If I understand correctly, these are the authoritative on-disk paths, independent of `--symlink_prefix`. It falls back to `<execution_root>/<path_prefix>/<name>` for non-`file://` URIs (e.g. `bytestream://` outputs from remote builds that were downloaded locally via `--remote_download_outputs=toplevel`). Note this only resolves where an output lives; under `--remote_download_minimal` the bytes are never materialized locally, so downstream consumers still fail regardless of the path returned. This also extracts the per-`File` resolution into a pure `_resolve_output_path(file, exec_root)` helper function and thus makes the logic unit-testable without shelling out to Bazel. The execution root is resolved lazily (and at most once) via `functools.lru_cache` to keep the unnecessary `bazel info` off the local-build path. A non-`localhost` URI authority is preserved as a `//host/...` UNC path rather than silently dropped. Adds tests covering `file://` decoding (including percent-encoding and authorities) and the `path_prefix` fallback.
9cde57d to
f163839
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #53.
_build_multiple_targetscurrently joints the workspace directory with each output'spath_prefix(bazel-out/...), which only resolves through the defaultbazel-outconvenience symlink. Under a non-default--symlink_prefix(e.g.--symlink_prefix=.bazel/) that symlink doesn't exist, so the returned paths point nowhere and packaging fails.This commit refactors the resolution to prefer
file://URI that Bazel emits in the BEPFilemessages. If I understand correctly, these are the authoritative on-disk paths, independent of--symlink_prefix. It falls back to<execution_root>/<path_prefix>/<name>for non-file://URIs (e.g.bytestream://outputs from remote builds that were downloaded locally via--remote_download_outputs=toplevel). Note this only resolves where an output lives; under--remote_download_minimalthe bytes are never materialized locally, so downstream consumers still fail regardless of the path returned.This also extracts the per-
Fileresolution into a pure_resolve_output_path(file, exec_root)helper function and thus makes the logic unit-testable without shelling out to Bazel. The execution root is resolved lazily (and at most once) viafunctools.lru_cacheto keep the unnecessarybazel infooff the local-build path. A non-localhostURI authority is preserved as a//host/...UNC path rather than silently dropped. Adds tests coveringfile://decoding (including percent-encoding and authorities) and thepath_prefixfallback.Implemented with the help of
gemini-cli.