From 10e56e8ed678bd67965bcda13f7902559fff05ab Mon Sep 17 00:00:00 2001 From: Xavier Bustamante Talavera Date: Tue, 18 Sep 2018 16:05:54 +0200 Subject: [PATCH] Use venv from mod-apache --- examples/apache.conf | 4 +++- examples/wsgi.wsgi | 23 ++++------------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/examples/apache.conf b/examples/apache.conf index b1a3ee1c..cd337c86 100644 --- a/examples/apache.conf +++ b/examples/apache.conf @@ -8,11 +8,13 @@ Define appdir /path/to/app/dir # The path where the app directory is. Apache must have access to this folder. Define wsgipath ${appdir}/wsgi.wsgi # The location of the .wsgi file +Define pyvenv /path/to/venv +# The path where the virtual environment is (the folder containing bin/activate) ServerName ${servername} - WSGIDaemonProcess "${servername}" threads=5 lang='en_US.UTF-8' locale='en_US.UTF-8' + WSGIDaemonProcess "${servername}" threads=5 lang='en_US.UTF-8' locale='en_US.UTF-8' python-home="${pyvenv}" WSGIScriptAlias / ${wsgipath} # pass the required headers through to the application diff --git a/examples/wsgi.wsgi b/examples/wsgi.wsgi index 10ef4912..c9c1722d 100644 --- a/examples/wsgi.wsgi +++ b/examples/wsgi.wsgi @@ -3,7 +3,7 @@ An exemplifying Apache python WSGI to a Devicehub app. Based in http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/ -You only need to modify ``app_dir`` and ``venv``. +You only need to modify ``app_dir``. """ from pathlib import Path @@ -11,28 +11,13 @@ from pathlib import Path import sys app_dir = Path(__file__).parent -""" -The **directory** where app.py is located. -Change this accordingly. -""" +"""The **directory** where app.py is located. Change this accordingly.""" + assert app_dir.is_dir(), 'app_dir must point to a directory: {}'.format(app_dir) app_dir = str(app_dir.resolve()) -venv = Path(__file__).parent.parent / 'venv' / 'bin' / 'activate_this.py' -""" -The location of the ``activate_this.py`` file of the virtualenv. -Change this accordingly. -""" -assert venv.is_file(), 'venv must point to a file: {}'.format(venv) -venv = str(venv.resolve()) - -# Load the virtualenv -# ------------------- -_globals = dict(__file__=venv) -exec(open(venv).read(), _globals) - # Load the app # ------------ sys.path.insert(0, str(app_dir)) # noinspection PyUnresolvedReferences -from app import app as application \ No newline at end of file +from app import app as application