Conversation
7e98a0a to
45330f8
Compare
|
It appears that I've missed a few other test cases that have also been affected by the changes. I will review and update. |
|
There were some tests that were failing due to having hardcoded pyvenv.cfg line numbers that I've fixed. There is a remaining failure related to symlink venvs introduced in #11083 that I need to look a little bit more into. |
6d195f2 to
df37c45
Compare
|
I think we were also considering making the See @charliermarsh / @konstin thoughts? |
|
Ah, you already saw this :) Was just about to ask for feedback. The remaining CI failure (in benchmarks) is due to not fully resolving relative paths "that go up". I think this is fixable by using I also wonder what you think (@zanieb) of the change I made to the symlink test. I think the behaviour (with my changes) is correct, but it might not be "in the spirit of the test" now. Perhaps it would be more correct to change it to use a relocatable venv. |
Summary
Virtual environments are not relocatable (by default) in particular due to hardcoded paths in shebangs of scripts. While it is perhaps not very common to move a virtual environment by itself, it is not unthinkable that a user might reorganize his projects and hence effectively also the virtual environments. This can lead to weird errors, for example if a call to pytest "falls through" to the system installation instead of the (broken) entrypoint in the virtual environment.
This change adds a field
uv-venv-pathtopyvenv.cfg. The field is only added when the venv is not relocatable. Whenuvlooks for usable venvs when e.g. syncing, it verifies that this path matches the actual path of the venv. If it does not match, the venv will be deleted and recreated.Fixes #10895
Test Plan
pyvenv.cfgfor non-relocatable (default,uv-venv-pathpresent) and relocatable venvs (uv-venv-pathabsent).sync_invalid_environmentto check that the venv is recreated whenuv-venv-pathdoes not match the actual path.uv-venv-pathis absent frompyvenv.cfg(this will recreate the venv).