]> git.phdru.name Git - dotfiles.git/blob - .vim/python/virtualenv.py
ca66bf8854095a10d459ace69cf34b4ac63066bd
[dotfiles.git] / .vim / python / virtualenv.py
1 import sys, os
2
3 virtualenv_dir = os.environ.get('VIRTUAL_ENV')
4 if virtualenv_dir:
5     sys.path.insert(0, virtualenv_dir)
6     for activate_this in [
7         os.path.join(virtualenv_dir, 'bin', 'activate_this.py'),
8         os.path.join(virtualenv_dir, 'Scripts', 'activate_this.py')
9     ]:
10         if not os.path.exists(activate_this):
11             continue
12         if sys.version_info[0] == 2:
13             if os.path.exists(
14                     os.path.join(virtualenv_dir, 'lib', 'python2.7')):
15                 execfile(activate_this,
16                          dict(__file__=activate_this))
17         else:
18             if not os.path.exists(
19                     os.path.join(virtualenv_dir, 'lib', 'python2.7')):
20                 exec(open(activate_this, 'r').read(),
21                      dict(__file__=activate_this))
22         break