Add support for a $sitedir/venv directory and activate it when found.
Review Request #13056 — Created May 19, 2023 and submitted — Latest diff uploaded
As part of an effort to move toward encouraging virtualenv-based
management of Review Board installs, this change updates our WSGI
entrypoint and our auto-generated configurations to detect and
sanity-check a virtualenv setup and activate it if available.
reviewboard/wsgi.py
now looks to see if we have a$sitedir/venv
directory. If it exists, and we're not already in a virtualenv, it will
make sure the right files are present and then activate it. If anything
is missing, aRuntimeError
will be raised with instructions, helping
admins sort out the issue.Validation checks for the presence of an
activate_this.py
(which is
created byvirtualenv
but notpython -m venv
) and apythonX.Y
binary matching the currently-executing Python version.Environment variables are built from the new state, ensuring
subprocesses will see the correct versions of binaries and packages.This also adds a
$sitedir/bin
to$PATH
, giving us a place to put
executables likep4
without placing them in system directories.
Tested with both a global Python and a virtualenv-backed install.
Verified that thevenv
directory was present for a virtualenv-backed
install, and that its environment was properly used in a default Apache,
uWSGI, and Gunicorn setup.Tested pruning some of the virtualenv dir to hit the WSGI error checks.
Verified the resulting errors.