summaryrefslogtreecommitdiffhomepage
path: root/auto/modules/python
diff options
context:
space:
mode:
authorTiago Natel de Moura <t.nateldemoura@f5.com>2020-05-28 14:57:41 +0100
committerTiago Natel de Moura <t.nateldemoura@f5.com>2020-05-28 14:57:41 +0100
commite2b53e16c60ba1e3bbbe59172c184e97f889326b (patch)
treef2bda4ea966657fc52189d154e1d6afcb767973f /auto/modules/python
parente9e5ddd5a5d9ce99768833137eac2551a710becf (diff)
downloadunit-e2b53e16c60ba1e3bbbe59172c184e97f889326b.tar.gz
unit-e2b53e16c60ba1e3bbbe59172c184e97f889326b.tar.bz2
Added "rootfs" feature.
Diffstat (limited to 'auto/modules/python')
-rw-r--r--auto/modules/python34
1 files changed, 33 insertions, 1 deletions
diff --git a/auto/modules/python b/auto/modules/python
index 6c8198f5..ad862f3c 100644
--- a/auto/modules/python
+++ b/auto/modules/python
@@ -68,6 +68,7 @@ if /bin/sh -c "$NXT_PYTHON_CONFIG --prefix" >> $NXT_AUTOCONF_ERR 2>&1; then
NXT_PYTHON_CONFIG="${NXT_PYTHON_CONFIG} --embed"
fi
+ NXT_PYTHON_EXEC=`${NXT_PYTHON_CONFIG} --exec-prefix`/bin/${NXT_PYTHON}
NXT_PYTHON_INCLUDE=`${NXT_PYTHON_CONFIG} --includes`
NXT_PYTHON_LIBS=`${NXT_PYTHON_CONFIG} --ldflags`
@@ -129,6 +130,37 @@ if grep ^$NXT_PYTHON_MODULE: $NXT_MAKEFILE 2>&1 > /dev/null; then
exit 1;
fi
+
+NXT_PYTHON_MOUNTS_HEADER=$NXT_BUILD_DIR/nxt_python_mounts.h
+
+$NXT_PYTHON_EXEC -c 'import os.path
+import sys
+pyver = "python" + str(sys.version_info[0]) + "." + str(sys.version_info[1])
+
+print("static const nxt_fs_mount_t nxt_python%d%d_mounts[] = {" % (sys.version_info[0], sys.version_info[1]))
+
+pattern = "{(u_char *) \"%s\", (u_char *) \"%s\", (u_char *) \"bind\", NXT_MS_BIND|NXT_MS_REC, NULL},"
+base = None
+for p in sys.path:
+ if len(p) > 0:
+ if os.path.basename(p) == pyver:
+ base = p
+
+if base is None:
+ raise Exception("failed to compute sys.path mount points")
+
+print(pattern % (base, base))
+
+for p in sys.path:
+ if len(p) > 0:
+ if not p.startswith(base):
+ print(pattern % (p, p))
+
+print("};\n\n")
+
+' >> $NXT_PYTHON_MOUNTS_HEADER
+
+
$echo " + Python module: ${NXT_PYTHON_MODULE}.unit.so"
. auto/cc/deps
@@ -165,7 +197,7 @@ END
done
-
+
cat << END >> $NXT_MAKEFILE
.PHONY: ${NXT_PYTHON_MODULE}