From 353abf00b2c4c65a8befd5efa8d992e56667c257 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 18 Jan 2024 15:55:38 +0300 Subject: [PATCH] Feat(.vim/python/virtualenv.py): Check major Python version Do not activate the current virtual environment if it doesn't correspond to the vim's Python version. --- .vim/python/virtualenv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.vim/python/virtualenv.py b/.vim/python/virtualenv.py index 9341bc7..ca66bf8 100644 --- a/.vim/python/virtualenv.py +++ b/.vim/python/virtualenv.py @@ -10,7 +10,13 @@ if virtualenv_dir: if not os.path.exists(activate_this): continue if sys.version_info[0] == 2: - execfile(activate_this, dict(__file__=activate_this)) + if os.path.exists( + os.path.join(virtualenv_dir, 'lib', 'python2.7')): + execfile(activate_this, + dict(__file__=activate_this)) else: - exec(open(activate_this, 'r').read(), dict(__file__=activate_this)) + if not os.path.exists( + os.path.join(virtualenv_dir, 'lib', 'python2.7')): + exec(open(activate_this, 'r').read(), + dict(__file__=activate_this)) break -- 2.39.2