【问题标题】:Can you use QT in a ReadTheDocs build without mocking?你可以在没有模拟的情况下在 ReadTheDocs 构建中使用 QT 吗?
【发布时间】:2020-12-02 04:21:20
【问题描述】:

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

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

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 相关。

这是因为运行构建的虚拟机实际上没有显示器吗?有没有办法解决这个问题?

【问题讨论】:

    标签: python python-sphinx pyside2 read-the-docs xcb


    【解决方案1】:

    这是因为运行构建的虚拟机实际上没有显示器吗?

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

    有没有办法解决这个问题?

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

    【讨论】:

    • 谢谢,这看起来正是我想要的!我最终只是坚持使用模拟,因为它更容易在 ReadTheDocs 构建中使用。您无法控制在 ReadTheDocs 上运行的 sphinx 命令,因此无法执行 xvfb-run sphinx-build ...。可以按照 sphinx conf.py 中的 subprocess.run 命令中的 here 所述启动 xvfb。
    猜你喜欢
    • 2012-02-08
    • 2020-09-29
    • 1970-01-01
    • 2011-06-30
    • 2020-09-06
    • 2021-11-04
    • 1970-01-01
    • 2021-01-22
    • 1970-01-01
    相关资源
    最近更新 更多