fix: Normalize main script path in Python bootstrap#2925
Merged
rickeylev merged 8 commits intobazel-contrib:mainfrom May 23, 2025
Merged
fix: Normalize main script path in Python bootstrap#2925rickeylev merged 8 commits intobazel-contrib:mainfrom
rickeylev merged 8 commits intobazel-contrib:mainfrom
Conversation
Collaborator
|
Mostly LGTM. Mostly just needs a test. IIUC, the basic target def is this? ? For the test:
Does this problem exist in the bootstrap=script impl, too? |
Use os.path.normpath() to resolve "_main/../repo" to "repo"
and convert forward slashes to backward slashes on Windows.
This fixes an issue where "_main" doesn't exist and in turn
"assert os.path.exists("_main/../repo")" fails. This happens
for example when packaging a py_binary from a foreign repo
into a tar/container.
6cf8121 to
edba3a2
Compare
mering
commented
May 23, 2025
95a147b to
2ec6eab
Compare
2ec6eab to
88e2e36
Compare
This is required to correctly populate runfiles in pkg_tar with include_runfiles=True.
3cbb2f2 to
312ec4d
Compare
312ec4d to
ac1c7db
Compare
Collaborator
|
LGTM. Thanks for slogging through that test @mering ! Recapping our chat, for posterity: We'll skip testing this on windows. The error is about the "launcher" being unable to find the python.exe file, which is probably just an artifact of the sh_test/tar/extract layout of files and/or env variable state. Something to look into another time. I'm fairly certain this bug doesn't exist in the script implementation because it uses runfiles-root relative paths instead of main-repo-relative paths. It'd be nice to have a test for that regardless, but that doesn't need to go into this PR. |
rickeylev
approved these changes
May 23, 2025
88e2e36 to
2abee57
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.
Use
os.path.normpath()to resolve_main/../repo/torepo/and convert forwardslashes to backward slashes on Windows.
This fixes an issue where
_maindoesn't exist within runfiles and in turn thelater assertion that the path to main exists fails (~L542). This happens,
for example, when packaging a
py_binaryfrom a foreign repo into a tar/container.