-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.py
More file actions
27 lines (23 loc) · 754 Bytes
/
environment.py
File metadata and controls
27 lines (23 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
"""Add current directory to Python's site-packages path.
"""
import os
import site
import sys
ROOT = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(ROOT, *a)
prev_sys_path = list(sys.path)
site.addsitedir(path('lib'))
site.addsitedir(path('handlers'))
if os.path.exists(path('vendor')):
for directory in os.listdir(path('vendor')):
full_path = path('vendor/%s' % directory)
if os.path.isdir(full_path):
site.addsitedir(full_path)
# Move the new items to the front of sys.path. (via virtualenv)
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path