Files
zulip/scripts/lib/setup_path_on_import.py
julianasobreira df2d448f7b python: Add lint rule banning 'from os.path import'.
This enforces our use of a consistent style in how we access Python
modules; "from os.path import dirname" is a particularly popular
abbreviation inconsistent with our style, and so it deserves a lint
rule.

Commit message and error text tweaked by tabbott.

Fixes #6543.
2017-09-22 04:55:38 -07:00

19 lines
512 B
Python

"""
Use libraries from a virtualenv (by modifying sys.path) in production.
Also add Zulip's root directory to sys.path
"""
import os.path
import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
activate_this = os.path.join(
BASE_DIR,
"zulip-py3-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))
sys.path.append(BASE_DIR)