Skip to content
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

Detect if project directory was moved for venv reconstruction #10895

Open
jonaslb opened this issue Jan 23, 2025 · 1 comment
Open

Detect if project directory was moved for venv reconstruction #10895

jonaslb opened this issue Jan 23, 2025 · 1 comment
Labels
enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged

Comments

@jonaslb
Copy link

jonaslb commented Jan 23, 2025

Summary

I just had an issue with pytest á la #7260. Turned out that because I had moved the project directory, the shebang in the "pytest" script in the venv was wrong, and apparently this meant that the command would fallthrough to the system-installed pytest which couldn't find my project or any of its dependencies, of course. uv sync would not detect this, but deleting .venv did the trick.

So I thought, since the location of the venv is hardcoded in the entrypoint scripts, it would be appropriate for uv to keep track of whether the venv location has changed. For example, it could go into the pyvenv.cfg file under a uv-venv-path variable or such. Then, if the actual path of the venv does not match this value, it would indicate to uv that the venv (or at least the entrypoints) should be reconstructed.

Example

No response

@jonaslb jonaslb added the enhancement New feature or improvement to existing functionality label Jan 23, 2025
@zanieb
Copy link
Member

zanieb commented Jan 23, 2025

Yeah it makes sense to detect and invalidate the .venv in this case, if we can.

@zanieb zanieb added the help wanted Contribution especially encouraged label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged
Projects
None yet
Development

No branches or pull requests

2 participants