uwsgi,使用自定义 python 安装构建 python 插件

uwsgi, build python plugin with custom python instalation

我想从目录 /opt/python36 下的自定义 python 安装中为 uwsgi 构建 python_plugin。 如何在构建期间设置 python 的路径? 我在下面发出 运行 命令,但该插件是用 OS Cent 7 附带的 Python 2.7 组装的。

PYTHON=python3.6; /usr/sbin/uwsgi  --build-plugin 
"/usr/src/uwsgi/2.0.15/plugins/python/ python36" 

我使用了一个肮脏的解决方案。我临时用自定义的替换了 shipped python,编译 uwsgi 插件然后设置回 shipped python.

rm -f /usr/bin/python; ln -s  /opt/python3/bin/python3 /usr/bin/python;  # set correct python

PYTHON=python3.6; /usr/sbin/uwsgi  --build-plugin "/usr/src/uwsgi/2.0.15/plugins/python/ python36" # commpile uwsgi plugin

strings  python36_plugin.so|grep '3.6' # test python version

chmod 644 ./python36_plugin.so ; mv ./python36_plugin.so  /usr/lib64/uwsgi/;

rm -f /usr/bin/python; ln -s  /usr/bin/python2  /usr/bin/python # --> set back shipped python

只需 cd 进入所需目录:

cd /opt/python36 && uwsgi --build-plugin "/usr/src/uwsgi/plugins/python python36"

您可以在 PYTHON 环境变量中包含 python 二进制文件的完整路径:

$ PYTHON=/opt/python36/bin/python3.6 /usr/sbin/uwsgi --build-plugin 
"/usr/src/uwsgi/2.0.15/plugins/python/ python36"