| OLD | NEW |
| (Empty) |
| 1 """By using execfile(this_file, dict(__file__=this_file)) you will | |
| 2 activate this virtualenv environment. | |
| 3 | |
| 4 This can be used when you must use an existing Python interpreter, not | |
| 5 the virtualenv bin/python | |
| 6 """ | |
| 7 | |
| 8 try: | |
| 9 __file__ | |
| 10 except NameError: | |
| 11 raise AssertionError( | |
| 12 "You must run this like execfile('path/to/activate_this.py', dict(__file
__='path/to/activate_this.py'))") | |
| 13 import sys | |
| 14 import os | |
| 15 | |
| 16 old_os_path = os.environ.get('PATH', '') | |
| 17 os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + o
ld_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') | |
| 21 else: | |
| 22 site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'sit
e-packages') | |
| 23 prev_sys_path = list(sys.path) | |
| 24 import site | |
| 25 site.addsitedir(site_packages) | |
| 26 sys.real_prefix = sys.prefix | |
| 27 sys.prefix = base | |
| 28 # Move the added items to the front of the path: | |
| 29 new_sys_path = [] | |
| 30 for item in list(sys.path): | |
| 31 if item not in prev_sys_path: | |
| 32 new_sys_path.append(item) | |
| 33 sys.path.remove(item) | |
| 34 sys.path[:0] = new_sys_path | |
| OLD | NEW |