Skip to content

Commit 427c466

Browse files
committed
source project-dir/.virtualenvwrapper/predeactivate when deactivating
1 parent d258453 commit 427c466

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ project = "virtualenvwrapper.project:post_activate_source"
9393
user_scripts = "virtualenvwrapper.user_scripts:post_activate_source"
9494

9595
[project.entry-points."virtualenvwrapper.pre_deactivate_source"]
96+
project = "virtualenvwrapper.project:pre_deactivate_source"
9697
user_scripts = "virtualenvwrapper.user_scripts:pre_deactivate_source"
9798

9899
[project.entry-points."virtualenvwrapper.post_deactivate_source"]

virtualenvwrapper/project.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import logging
99
import os
1010

11-
from virtualenvwrapper.user_scripts import make_hook, run_global, PERMISSIONS
11+
from virtualenvwrapper.user_scripts import PERMISSIONS, make_hook, run_global
1212

1313
log = logging.getLogger(__name__)
1414

@@ -64,3 +64,13 @@ def post_activate_source(args):
6464
fi
6565
fi
6666
"""
67+
68+
69+
def pre_deactivate_source(args):
70+
return """
71+
if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ]; then
72+
if [ -f "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")/.virtualenvwrapper/predeactivate" ]; then
73+
source "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")/.virtualenvwrapper/predeactivate"
74+
fi
75+
fi
76+
"""

0 commit comments

Comments
 (0)