1- """ Support virtualenv in pymode. """
1+ """Support virtualenv in pymode."""
22
33import os
44import sys
99
1010@env .catch_exceptions
1111def enable_virtualenv ():
12- """ Enable virtualenv for vim.
12+ """Enable virtualenv for vim.
1313
1414 :return bool:
1515
@@ -25,32 +25,14 @@ def enable_virtualenv():
2525 env .message ('Virtualenv %s already enabled.' % path )
2626 return env .stop ()
2727
28- activate_this = os .path .join (os .path .join (path , 'bin' ), 'activate_this.py' )
29-
30- # Fix for windows
31- if not os .path .exists (activate_this ):
32- activate_this = os .path .join (
33- os .path .join (path , 'Scripts' ), 'activate_this.py' )
34-
35- try :
36- with open (activate_this ) as f :
37- source = f .read ()
38- exec (compile ( # noqa
39- source , activate_this , 'exec' ), dict (__file__ = activate_this ))
40- except IOError :
41- _activate_env_from_path (path )
42-
28+ activate_env_from_path (path )
4329 env .message ('Activate virtualenv: ' + path )
4430 env .let ('g:pymode_virtualenv_enabled' , path )
4531 return True
4632
4733
48- def _activate_env_from_path (env_path ):
49- """ Fix when `activate_this.py` does not exist.
50-
51- For Python 3.3 and newer, a new command-line tool `pyvenv` create venv
52- will not provide 'activate_this.py'.
53- """
34+ def activate_env_from_path (env_path ):
35+ """Activate given virtualenv."""
5436 prev_sys_path = list (sys .path )
5537
5638 if sys .platform == 'win32' :
0 commit comments