From: pshem <[email protected]>
Committer: GitHub <[email protected]>
Branch: master

PYTHON_MODULES for module dependencies

Use $PYTHON_MODULES to include additional python modules in the unikernel. Modules specified in this bash array will be imported the same way as python would import them(respecting virtual environments, etc.), but will not auto-resolve dependencies.

---
diff --git a/python3x/GET b/python3x/GET
--- a/python3x/GET
+++ b/python3x/GET
@@ -8,6 +8,8 @@ PYTHON_PREFIX_DIR=`python3 -c 'import sys; print(sys.prefix)'` PYTHON_MAJOR_VERSION=`python3 -c 'import sys; print(sys.version_info.major)'` PYTHON_MINOR_VERSION=`python3 -c 'import sys; print(sys.version_info.minor)'`
 PYTHON_VERSION="${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}"
+PYTHON_MODULES="" #put additional modules here. Include their dependencies. Example: "django mysql mysql.connector"
+

 install_shlibs() {
 SHLIBS=""
@@ -41,6 +43,13 @@ do
--exclude '*.pyc' --exclude '*.pyo' --exclude '*.egg-info' --exclude 'site-packages' --exclude 'dist-packages'
 done

+for i in ${PYTHON_MODULES}
+do
+ rsync -a "$(python3 -c "import sys; module = sys.argv[1]; exec('import ' + module); print(eval(module + '.__file__')) if str(eval(module + '.__file__').split('/')[-1]) != '__init__.py' else print(eval(module + '.__path__[0]'))" $i)" \ + $ROOTFS/lib/python${PYTHON_VERSION}/ --safe-links --exclude test --exclude unittest \
+    --exclude '*.pyc' --exclude '*.pyo' --exclude '*.egg-info'
+done
+
 SHLIBS_COUNT4=`install_shlibs`
 echo "Python SHLIBS_COUNT4=$SHLIBS_COUNT4"
 SHLIBS_COUNT3=`install_shlibs`

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to