1
- """ Support virtualenv in pymode. """
1
+ """Support virtualenv in pymode."""
2
2
3
3
import os
4
4
import sys
9
9
10
10
@env .catch_exceptions
11
11
def enable_virtualenv ():
12
- """ Enable virtualenv for vim.
12
+ """Enable virtualenv for vim.
13
13
14
14
:return bool:
15
15
@@ -25,32 +25,14 @@ def enable_virtualenv():
25
25
env .message ('Virtualenv %s already enabled.' % path )
26
26
return env .stop ()
27
27
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 )
43
29
env .message ('Activate virtualenv: ' + path )
44
30
env .let ('g:pymode_virtualenv_enabled' ,path )
45
31
return True
46
32
47
33
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."""
54
36
prev_sys_path = list (sys .path )
55
37
56
38
if sys .platform == 'win32' :