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

Use os.path.lexists when checking for virtualenvs #3857

Merged
merged 1 commit into from
Aug 14, 2016

Conversation

mx-moth
Copy link
Contributor

@mx-moth mx-moth commented Jul 20, 2016

This is a fix for a fairly contrived situation I experience because of my particular development environment. For development, I run projects within a Vagrant virtual machine, with the source code living on my host machine (in project/), shared in to the virtual machine guest. I create a virtual environment on my host machine in this directory (project/venv) so that my editor can do code completion, etc. I run, test, and package the code on the the guest machine. When running pip install -e . or similar commands on the guest, the code within pip fails to detect the virtual environment created on the host machine as a virtual environment, causing the command to delve down through the virtual environment directories despite pip attempting to filter virtual environments out. This makes the pip install -e . command take about a minute to run, compared to the few seconds when the virtual environment is correctly ignored.

pip fails to detect the virtual environment in this particular case, as pip uses os.path.exists() to check that project/venv/bin/python exists. This file does exist, but is a symlink to the python executable provided by the system. On my host, the target file does exist, but in the guest (which may use a different version of Python, or structure its directories differently, or...), the target file does not exist. os.path.exists() returns False for dangling symlinks, causing the virtual environment detection code to fail.

This change uses os.path.lexists() instead of os.path.exists(), which returns True for dangling symlinks.

@xavfernandez xavfernandez added this to the 8.2 milestone Jul 21, 2016
@xavfernandez
Copy link
Member

@timheap a small changelog would be lovely

@mx-moth
Copy link
Contributor Author

mx-moth commented Aug 14, 2016

I've added a note to CHANGES.txt, and rebase on latest master.

@xavfernandez xavfernandez merged commit da22abb into pypa:master Aug 14, 2016
@xavfernandez
Copy link
Member

Thanks a lot ! 👍

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants