-
Notifications
You must be signed in to change notification settings - Fork 6
/
encore.wsgi.example
executable file
·34 lines (30 loc) · 1.15 KB
/
encore.wsgi.example
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
28
29
30
31
32
33
34
#! /usr/bin/python3
# Uncomment and replace encore-path with path to repo folder
import os, sys
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
# PROJECT_DIR = 'encore-path'
def activate_venv(__file__):
old_os_path = os.environ.get('PATH', '')
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
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
activate_this = os.path.join(PROJECT_DIR, 'venv', 'bin', 'activate')
activate_venv(activate_this)
sys.path.insert(0, PROJECT_DIR)
from encore import create_app
application = create_app(os.path.join(PROJECT_DIR, "flask_config.py"))