aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-02-07 20:14:06 +0000
committerMichael Elkins <melkins@tislabs.com>2012-02-07 20:14:06 +0000
commit354779d487dbeb03fa4668093591547fc927e5ad (patch)
tree696fbfd1212b0a258dc02c8fb0be0f878e1ab360
parent9541365959d9b5c1cb2ee94f7cb9fc96eb3aaf14 (diff)
make configure detect when running inside of virtualenv so that the rpki.wsgi script can be generated properly
make rpki.wsgi be generated used a sed script rather than make-django-script svn path=/branches/tk161/; revision=4312
-rwxr-xr-xconfigure13
-rw-r--r--configure.ac8
-rw-r--r--rpkid/Makefile.in5
-rw-r--r--rpkid/portal-gui/rpki.wsgi.in27
4 files changed, 40 insertions, 13 deletions
diff --git a/configure b/configure
index c15c6db1..92057799 100755
--- a/configure
+++ b/configure
@@ -640,6 +640,7 @@ LIBOBJS
DJANGO_ADMIN
DJANGO_DIR
SECRET_KEY
+VIRTUAL_ENV
OPENSSL_SO_GLOB
OPENSSL_CONFIG_COMMAND
RPKID_SUBDIRS
@@ -4928,6 +4929,18 @@ fi
if test $build_django = yes
then
+ { $as_echo "$as_me:$LINENO: checking if running under virtualenv" >&5
+$as_echo_n "checking if running under virtualenv... " >&6; }
+ if test x$VIRTUAL_ENV != x; then
+ VIRTUAL_ENV=$VIRTUAL_ENV
+
+ { $as_echo "$as_me:$LINENO: result: $VIRTUAL_ENV" >&5
+$as_echo "$VIRTUAL_ENV" >&6; }
+ else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+
# source: http://blog.leosoto.com/2008/04/django-secretkey-generation.html
SECRET_KEY=`$PYTHON -c 'import random; print "".join(random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50))'`
diff --git a/configure.ac b/configure.ac
index 03d321c4..b1508796 100644
--- a/configure.ac
+++ b/configure.ac
@@ -394,6 +394,14 @@ fi
if test $build_django = yes
then
+ AC_MSG_CHECKING([if running under virtualenv])
+ if test x$VIRTUAL_ENV != x; then
+ AC_SUBST(VIRTUAL_ENV, [$VIRTUAL_ENV])
+ AC_MSG_RESULT([$VIRTUAL_ENV])
+ else
+ AC_MSG_RESULT(no)
+ fi
+
# source: http://blog.leosoto.com/2008/04/django-secretkey-generation.html
AC_SUBST(SECRET_KEY, `$PYTHON -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'`)
diff --git a/rpkid/Makefile.in b/rpkid/Makefile.in
index 0b18d9a2..2c2fe6dc 100644
--- a/rpkid/Makefile.in
+++ b/rpkid/Makefile.in
@@ -5,6 +5,7 @@ PYTHON = @PYTHON@
SECRET_KEY = @SECRET_KEY@
DJANGO_DIR = @DJANGO_DIR@
+VIRTUAL_ENV = @VIRTUAL_ENV@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@ @POW_LDFLAGS@
@@ -244,7 +245,9 @@ portal-gui/scripts/rpkigui-import-routes: portal-gui/scripts/rpkigui-import-rout
${COMPILE_DJANGO}
portal-gui/rpki.wsgi: ${srcdir}/portal-gui/rpki.wsgi.in
- ${COMPILE_DJANGO}
+ sed -e "s|@VIRTUAL"_"ENV@|${VIRTUAL_ENV}|" \
+ -e "s|@PYTHON""PATH@|${sysconfdir}/rpki|" \
+ ${srcdir}/portal-gui/rpki.wsgi.in > portal-gui/rpki.wsgi
portal-gui/settings.py: ${srcdir}/portal-gui/settings.py.in
${COMPILE_SETTINGS}
diff --git a/rpkid/portal-gui/rpki.wsgi.in b/rpkid/portal-gui/rpki.wsgi.in
index e4471d11..5dd5a7e3 100644
--- a/rpkid/portal-gui/rpki.wsgi.in
+++ b/rpkid/portal-gui/rpki.wsgi.in
@@ -17,20 +17,23 @@
__version__ = '$Id$'
-#prev_sys_path = list(sys.path)
+VIRTUAL_ENV = '@VIRTUAL_ENV@'
-# When used with virtualenv, specify the location of the python modules to use
-import site
-site.addsitedir('/home/melkins/web_portal/lib/python2.6/site-packages')
-
-#new_sys_path = []
-#for item in list(sys.path):
-# if item not in prev_sys_path:
-# new_sys_path.append(item)
-# sys.path.remove(item)
-#sys.path[:0] = new_sys_path
+import os
+import os.path
-#print sys.path
+# When used with virtualenv, specify the location of the python modules to use
+if VIRTUAL_ENV:
+ import site
+ # locate the site-packages directory
+ for (dp, dn, fn) in os.walk(VIRTUAL_ENV + '/lib'):
+ if 'site-packages' in dn:
+ site.addsitedir(os.path.join(dp, 'site-packages'))
+ break
+
+import sys
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+sys.path.insert(1, '@PYTHONPATH@')
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()