djtest: use pyelftools to find uwsgi ld.so
Change-Id: I54bdaa588ff15d8c6ca73c4307076a93a5682d78
diff --git a/personal/q3k/djtest/BUILD b/personal/q3k/djtest/BUILD
index d4ab6cc..8e82b25 100644
--- a/personal/q3k/djtest/BUILD
+++ b/personal/q3k/djtest/BUILD
@@ -5,6 +5,7 @@
srcs = glob(["djtest/**/*.py"]),
deps = [
requirement("django"),
+ requirement("pytz"),
requirement("sqlparse"),
],
)
@@ -24,5 +25,6 @@
":app",
"@bazel_tools//tools/python/runfiles",
requirement("uwsgi"),
+ requirement("pyelftools"),
],
)
diff --git a/personal/q3k/djtest/uwsgi-start.py b/personal/q3k/djtest/uwsgi-start.py
index eb22d55..a5c325e 100644
--- a/personal/q3k/djtest/uwsgi-start.py
+++ b/personal/q3k/djtest/uwsgi-start.py
@@ -6,13 +6,24 @@
import bazel_tools
import bazel_tools.tools.python
+from elftools.elf.elffile import ELFFile
+from elftools.elf.segments import InterpSegment
+
from bazel_tools.tools.python.runfiles import runfiles
r = runfiles.Create()
uwsgi = r.Rlocation("pydeps_pypi__uWSGI_2_0_18/uWSGI-2.0.18.data/scripts/uwsgi")
-print(uwsgi)
settings = r.Rlocation("hscloud/personal/q3k/djtest/djtest/settings.py")
-print(settings)
+
+# uwsgi from runfiles is non-chmodded, we have to run it through its interpreter
+ld = None
+with open(uwsgi, 'rb') as f:
+ elffile = ELFFile(f)
+ for segment in elffile.iter_segments():
+ if isinstance(segment, InterpSegment):
+ ld = segment.get_interp_name()
+if ld is None:
+ raise Exception("could not find interpreter/ld.so path in uwsgi - failing")
apppath = os.path.dirname(settings)
sitepath = os.path.dirname(apppath)
@@ -35,8 +46,7 @@
cfgf.close()
args = [
- # uwsgi from runfiles is non-chmodded, run through interpreter
- '/lib64/ld-linux-x86-64.so.2',
+ ld,
uwsgi,
'--ini', cfgf.name,
]