This is an attempt to improve my previous pull request about making the auto-activation plugin 'project aware', so that virtualenvs of projects are automatically deactivated when leaving the project directory (#175). The solution back then was to only deactivate virtualenvs of projects automatically if they contain a .project file. However, this solution feels very unintuitive to me, partly because it seems against the 'intended' use of the projects plugin, which suggests to only use .project files if the project is not in the $PROJECT_HOME directory - and I like to keep all my projects in $PROJECT_HOME.
This patch aims to accommodate this workflow by auto-deactivating virtualenvs of projects in $PROJECT_HOME without needing .project or .venv files. It adds a check to the auto-activation plugin that auto-deactivates venvs if all of these conditions are true:
Virtualenv was not auto-activated (by an activation file) and doesn't contain a .project file
$PWD is not a subdirectory of $PROJECT_HOME (because projects are stored as $PROJECT_HOME/project1-dir, $PROJECT_HOME/project2-dir etc.)
By testing for these very specific conditions, this patch should not interfere with the normal usage of .venv and .project files in any way. Implementing this required very few code additions and the interaction between the auto-activation and projects plugin feels more intuitive to me: Now I can continue to use the projects plugin 'as intended' while benefiting from the convenience of the auto-activation plugin.
I've also updated the old comments explaning Projects plugin compatibility to reflect this change.
This is an attempt to improve my previous pull request about making the auto-activation plugin 'project aware', so that virtualenvs of projects are automatically deactivated when leaving the project directory (#175). The solution back then was to only deactivate virtualenvs of projects automatically if they contain a
.project
file. However, this solution feels very unintuitive to me, partly because it seems against the 'intended' use of the projects plugin, which suggests to only use.project
files if the project is not in the$PROJECT_HOME
directory - and I like to keep all my projects in$PROJECT_HOME
.This patch aims to accommodate this workflow by auto-deactivating virtualenvs of projects in
$PROJECT_HOME
without needing.project
or.venv
files. It adds a check to the auto-activation plugin that auto-deactivates venvs if all of these conditions are true:.project
file$PWD
is not a subdirectory of$PROJECT_HOME
(because projects are stored as$PROJECT_HOME/project1-dir
,$PROJECT_HOME/project2-dir
etc.)By testing for these very specific conditions, this patch should not interfere with the normal usage of
.venv
and.project
files in any way. Implementing this required very few code additions and the interaction between the auto-activation and projects plugin feels more intuitive to me: Now I can continue to use the projects plugin 'as intended' while benefiting from the convenience of the auto-activation plugin.I've also updated the old comments explaning Projects plugin compatibility to reflect this change.