mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
Activate virtualenv in production Python code.
The manage.py change effectively switches the Zulip production server to use the virtualenv, since all of our supervisord commands for the various Python services go through manage.py. Additionally, this migrates the production scripts and Nagios plugins to use the virtualenv as well.
This commit is contained in:
committed by
Tim Abbott
parent
64affb83f9
commit
a9835c0ab2
15
scripts/lib/setup_path_on_import.py
Normal file
15
scripts/lib/setup_path_on_import.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Use libraries from a virtualenv (by modifying sys.path) in production.
|
||||
Also add Zulip's root directory to sys.path
|
||||
"""
|
||||
|
||||
import os
|
||||
from os.path import dirname, abspath
|
||||
import sys
|
||||
|
||||
BASE_DIR = dirname(dirname(dirname(abspath(__file__))))
|
||||
activate_this = os.path.join(BASE_DIR, "zulip-venv", "bin", "activate_this.py")
|
||||
if os.path.exists(activate_this):
|
||||
# this file will exist in production
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577
|
||||
sys.path.append(BASE_DIR)
|
||||
Reference in New Issue
Block a user