cursed django example

Change-Id: I09ac506f53c25f5427f3d35d5efa4f40c83f48f9
diff --git a/personal/q3k/djtest/uwsgi-start.py b/personal/q3k/djtest/uwsgi-start.py
new file mode 100644
index 0000000..7597a6f
--- /dev/null
+++ b/personal/q3k/djtest/uwsgi-start.py
@@ -0,0 +1,44 @@
+import configparser
+import os
+import subprocess
+import tempfile
+
+import bazel_tools
+import bazel_tools.tools.python
+
+from bazel_tools.tools.python.runfiles import runfiles
+r = runfiles.Create()
+
+uwsgi = r.Rlocation("pip36/uwsgi/scripts/uwsgi")
+settings = r.Rlocation("__main__/personal/q3k/djtest/djtest/settings.py")
+
+apppath = os.path.dirname(settings)
+sitepath = os.path.dirname(apppath)
+
+pythonpath = os.environ['PYTHONPATH']
+
+# Make UWSGI ini config file
+cfgf = tempfile.NamedTemporaryFile(mode='w', delete=False)
+
+config = configparser.ConfigParser()
+config['uwsgi'] = {}
+config['uwsgi']['master'] = '1'
+config['uwsgi']['chdir'] = sitepath
+config['uwsgi']['module'] = 'djtest.wsgi'
+config['uwsgi']['env'] = 'DJANGO_SETTINGS_MODULE=djtest.settings'
+config['uwsgi']['http'] = '127.0.0.1:8080'
+config['uwsgi']['pythonpath'] = pythonpath
+
+config.write(cfgf)
+cfgf.close()
+
+args = [
+    # uwsgi from runfiles is non-chmodded, run through interpreter
+    '/lib64/ld-linux-x86-64.so.2',
+    uwsgi,
+    '--ini', cfgf.name,
+]
+
+subprocess.call(args)
+
+os.unlink(cfgf.name)