为 python 3.9 构建一个 uwsgi 插件失败,因为旧版本可以正常工作。还有其他选择吗?

Building a uwsgi plugin for python 3.9 failed for older version it works. Are there any other options?

我下载了最新的源代码uwsgi-2.0.19.1并尝试构建一个uwsgi插件 for python 3.9 但每次都失败了。对于 python3.6python3.8 等其他版本,它可以工作,我在其他 Django 项目中使用了它们。例如...

这里有效:


命令:

[user@me /uwsgi-2.0.19.1] $ make PROFILE=nolang

[user@me /uwsgi-2.0.19.1] $ PYTHON=python3.6 ./uwsgi --build-plugin "plugins/python python36"

输出:

*** uWSGI building and linking plugin from plugins/python ***
[gcc -pthread] python36_plugin.so
build time: 5 seconds
*** python36 plugin built and available in python36_plugin.so ***

命令:

[user@me /uwsgi-2.0.19.1] $ PYTHON=python3.8 ./uwsgi --build-plugin "plugins/python python38"

输出:

*** uWSGI building and linking plugin from plugins/python ***
[gcc -pthread] python38_plugin.so
build time: 5 seconds
*** python38 plugin built and available in python38_plugin.so ***

这里失败了:


“Datei oder Verzeichnis nicht gefunden”是德语,意思是“找不到文件或目录”。

命令:

[user@me /uwsgi-2.0.19.1] $ PYTHON=python3.9 ./uwsgi --build-plugin "plugins/python python39"

输出:

*** uWSGI building and linking plugin from plugins/python ***
[gcc -pthread] python39_plugin.so
In file included from plugins/python/python_plugin.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pyutils.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pyloader.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/wsgi_handlers.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/wsgi_headers.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/wsgi_subhandler.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/web3_subhandler.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/pump_subhandler.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/gil.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/uwsgi_pymodule.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/profiler.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/symimporter.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/tracebacker.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from plugins/python/raw.c:1:
plugins/python/uwsgi_python.h:2:10: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
    2 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
*** unable to build python39 plugin ***

问题:


好的。所以我的怀疑是对的 uwsgi-2.0.19.1 版本不支持 python 3.9。使用最新或较新的 uwsgi 版本,我可以为 python 3.9.

创建一个插件

希望这对遇到类似问题的其他人有所帮助。 我的问题是 uwsgi 总是使用 python3.8,而我希望它使用 python3.9(apt 安装和 pip3 等。没有任何效果,我无法获得 python3.9 uwsgi 插件)

我的解决方案是安装 python3.9-dev

$ sudo apt install python3.9-dev

而不仅仅是 'python3.9'

然后 $ python3 -m pip uninstall uwsgi

最后 $ python3 -m pip install --no-cache-dir uwsgi

这显然包含了所需的 uwsgi python3.9 插件,同时确保我删除了 apt 中任何缓存的 python3.8 内容 glhf!