diff --git a/scripts/lib/setup_path.py b/scripts/lib/setup_path.py index 2eb1a27803..751038c19f 100644 --- a/scripts/lib/setup_path.py +++ b/scripts/lib/setup_path.py @@ -7,9 +7,10 @@ import sys def setup_path() -> None: - if os.path.basename(sys.prefix) != "zulip-py3-venv": - BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - venv = os.path.join(BASE_DIR, "zulip-py3-venv") + BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + venv = os.path.realpath(os.path.join(BASE_DIR, "zulip-py3-venv")) + if sys.prefix != venv: + sys.path = list(filter(lambda p: "/zulip-py3-venv/" not in p, sys.path)) activate_this = os.path.join(venv, "bin", "activate_this.py") activate_locals = dict(__file__=activate_this) with open(activate_this) as f: