1
"""By using execfile(this_file, dict(__file__=this_file)) you will
2
activate this virtualenv environment.
4
This can be used when you must use an existing Python interpreter, not
5
the virtualenv bin/python
12
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
16
old_os_path = os.environ.get('PATH', '')
17
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
18
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19
if sys.platform == 'win32':
20
site_packages = os.path.join(base, 'Lib', 'site-packages')
22
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
23
prev_sys_path = list(sys.path)
25
site.addsitedir(site_packages)
26
sys.real_prefix = sys.prefix
28
# Move the added items to the front of the path:
30
for item in list(sys.path):
31
if item not in prev_sys_path:
32
new_sys_path.append(item)
34
sys.path[:0] = new_sys_path