-
-
Notifications
You must be signed in to change notification settings - Fork 663
fix(runfiles): assume main repository on Windows #3578
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
fix(runfiles): assume main repository on Windows #3578
Conversation
Summary of ChangesHello @rdesgroppes, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
f6d5265 to
06bf932
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a ValueError in CurrentRepository() on Windows by extending an existing workaround. The change correctly identifies the platform and assumes the main repository, which resolves the issue caused by incorrect runfiles environment variables. The code modification in python/runfiles/runfiles.py is clear and well-commented. As a positive side effect, the test in tests/runtime_env_toolchain/toolchain_runs_test.py is simplified by removing its own platform-specific workaround, which is now handled by the core fix. The changelog has also been updated appropriately. Overall, this is a solid fix.
06bf932 to
30c30a2
Compare
30c30a2 to
ffa350a
Compare
With any Python version on Windows, `RUNFILES_*` environment variables still point to an intermediate stage path instead of the module path, causing `CurrentRepository()` to raise a `ValueError` since `rules_python` v1.8.0: ``` ValueError: C:\Users\bot\AppData\Local\Temp\Bazel.runfiles_gh34ij5_\runfiles\+_repo_rules+cpython\my_script.py does not lie under the runfiles root C:/cache/ab1cdef2/execroot/_main/bazel-out/x64_windows-fastbuild/bin/external/+_repo_rules+cpython/install.exe.runfiles ``` This was not the case with `rules_python` v1.7.0. The issue stems from bazel-contrib#3086 which, by eliminating a wrong assumption, also brought a stricter behavior. Since bazel-contrib#3086 came up with a corresponding workaround in `//tests/runtime_env_toolchain:toolchain_runs_test`, the proposed fix simply consists in moving it to `CurrentRepository()`, thus adding another case to the workaround introduced by bazel-contrib#1634 for Python < 3.11. It therefore leads to assuming the main module path on Windows as well. Removing the workaround from `CurrentRepository()` would make the test fail as follows: ``` ==================== Test output for //tests/runtime_env_toolchain:toolchain_runs_test: E ====================================================================== ERROR: test_ran (__main__.RunTest.test_ran) ---------------------------------------------------------------------- Traceback (most recent call last): [...] ValueError: C:\Users\user\AppData\Local\Temp\Bazel.runfiles_1f08smy6\runfiles\_main\tests\runtime_env_toolchain\toolchain_runs_test.py does not lie under the runfiles root c:\users\user\_bazel_user\cxxeswjo\execroot\_main\bazel-out\x64_windows-fastbuild-st-c530e4918e48\bin\tests\runtime_env_toolchain\toolchain_runs_test.exe.runfiles ```
ffa350a to
6b54911
Compare
aignas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I think for the time being this might be good enough.
With any Python version on Windows,
RUNFILES_*environment variables still point to an intermediate stage path instead of the module path, causingCurrentRepository()to raise aValueErrorsincerules_pythonv1.8.0:This was not the case with
rules_pythonv1.7.0. The issue stems from #3086 which, by eliminating a wrong assumption, also brought a stricter behavior.Since #3086 came up with a corresponding workaround in
//tests/runtime_env_toolchain:toolchain_runs_test, the proposed fix simply consists in moving it toCurrentRepository(), thus adding another case to the workaround introduced by #1634 for Python < 3.11. It therefore leads to assuming the main module path on Windows as well.Removing the workaround from
CurrentRepository()would make the test fail as follows:Fixes #3579.