-
-
Notifications
You must be signed in to change notification settings - Fork 594
fix: Normalize main script path in Python bootstrap #2925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
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
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. |
88e2e36
to
2abee57
Compare
Use
os.path.normpath()
to resolve_main/../repo/
torepo/
and convert forwardslashes to backward slashes on Windows.
This fixes an issue where
_main
doesn'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_binary
from a foreign repo into a tar/container.