你能在没有模拟的情况下在 ReadTheDocs 构建中使用 QT 吗?

Can you use QT in a ReadTheDocs build without mocking?

我们的项目使用 QT (PySide2, qtpy) 并使用 sphinx autodoc 记录在 ReadTheDocs 上。到目前为止,我们已经模拟了大多数依赖项,但在这种特定情况下模拟 qtpy 非常复杂。我希望通过在 .readthedocs.yml.

condapython 部分安装依赖项来简化

安装似乎工作正常,但我在 RTD 构建的 sphinx 构建步骤中遇到错误:

qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Fatal Python error: Aborted

回溯指向我们代码中的行:QT_APP = QApplication(sys.argv).

我已经尝试设置 QT_DEBUG_PLUGINS=1,它给出了一些我无法做出任何结果的输出:

...
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/bin/platforms" ...
loaded library "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/platforms/libqeglfs.so"
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-docs'
QFactoryLoader::QFactoryLoader() checking directory path "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/egldeviceintegrations" ...
QFactoryLoader::QFactoryLoader() looking at "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/egldeviceintegrations/libqeglfs-emu-integration.so"
Found metadata in lib /home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/egldeviceintegrations/libqeglfs-emu-integration.so, metadata=
{
    "IID": "org.qt-project.qt.qpa.egl.QEglFSDeviceIntegrationFactoryInterface.5.5",
    "MetaData": {
        "Keys": [
            "eglfs_emu"
        ]
    },
    "archreq": 0,
    "className": "QEglFSEmulatorIntegrationPlugin",
    "debug": false,
    "version": 331520
}
...

并且我尝试通过设置 QT_QPA_PLATFORM=eglfs 来更改平台插件,这给出了类似的错误:Could not initialize egl display。谷歌搜索错误大多出现与 Raspberry Pi.

相关的问题

出现这种情况是因为虚拟机运行构建实际上没有显示器吗?有什么解决办法吗?

Is this happening because the virtual machine running the build doesn't actually have a display?

我猜是“是”。报错应该是Qt连接X11显示失败

Is there any way around this?

您可以尝试 运行在 xvfb-run 下设置您的构建脚本。因此,您应该 运行 xvfb-run 而不是 运行ning foo。这将设置一个无外设的 X11 服务器。