-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Switch to using lstat() instead of stat() to not match symlink targets #13161
base: main
Are you sure you want to change the base?
Conversation
See #13156 (comment) - I think the existing code should work without this change, and we need to understand why it doesn't before trying to "fix" the issue. |
ed0b04b
to
f6e5730
Compare
I'll leave this for someone familiar with Unix to comment on whether it's a good fix. It seems reasonable to me. |
f6e5730
to
211596f
Compare
5e3f8ee
to
d989254
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.
Looks reasonable and does the right thing locally. My best guess is that this worked in some limited situations because the virtual environment was created using copies instead of symlinks. This seems rare in practice as both venv and virtualenv have defaulted to using symlinks on Linux/macOS for ages, but I dunno what else could make this work.
The get_best_invocation_for_this_pip()
logic has the same flaw, although I doubt anyone uses symlinks for the pip binaries in practice (at least on Unix, the scripts' shebang includes a reference to the virtual environment's Python, so they can't be symlinks. Not sure how Windows works...).
625403a
to
0e47a0f
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.
Awesome, thank you very much!
I do want someone else to chime in before this lands though. While I've been using Linux daily for a few years ago, I still have my blindspots. I feel like I might've missed something here.
The convenience function samefile() calls stat() and samestat(), but this leads to treating a symlink and its target as the same which is unlikely to be intentional here as that doesn't work well with venv.
9348ec9
to
127134a
Compare
Closes #13156.