Python 如何在readthedocs上正确设置PyQt5导入?

Python 如何在readthedocs上正确设置PyQt5导入?,python,pyqt,read-the-docs,Python,Pyqt,Read The Docs,构建导入PyQt5的sphinx文档失败(),原因是 在tox.ini中,需要以下内容: [testenv:docs] # avoid QStandardPaths: XDG_RUNTIME_DIR not set passenv = XDG_RUNTIME_DIR # xvfb-run prevents Could not connect to any X display commands = /usr/bin/xvfb-run sphinx-build --color -W -b html

构建导入PyQt5的sphinx文档失败(),原因是

tox.ini
中,需要以下内容:

[testenv:docs]
# avoid QStandardPaths: XDG_RUNTIME_DIR not set
passenv = XDG_RUNTIME_DIR
# xvfb-run prevents Could not connect to any X display
commands = /usr/bin/xvfb-run sphinx-build --color -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
如何在readthedocs上做到这一点

这与,, 不幸的是,它不包含错误消息。PyQt5可从pip安装

注:

  • 在高级设置中,选中了使用setup.py Install在virtualenv中安装项目(但取消选中没有帮助)
  • 以下电位的参考快照为f33d233bf67bd7922ec864635e7589e7f4feb40f
触角 1.带模拟模块 也许PyQT5可以工作。但这似乎有点

改编自,添加

conf.py

    class _GRay(GCounterPart, QGraphicsPathItem):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
2.使用内置的sphinx
autodoc\u mock\u导入
与simpler相同的错误(仅在
conf.py
中添加了一行)

3.用定制的模拟 使用

屈服

  File ".../geoptics/guis/qt/main.py", line 59, in <module>
    app = QCoreApplication.instance()
AttributeError: type object 'QCoreApplication' has no attribute 'instance'
conf.py
中,与第二个暂定项一样,但多重继承被修饰符取代。本节介绍了这些变化

现在错误是

geoptics.guis.qt.handles.LineHandle.reset_move:1:term not in glossary: move restrictions
因为定义术语的geoptics类
\u GScene(QGraphicscene)
已被sphinx模仿掉,其文档也丢失了


在以下相关问题中留下的评论:


自动文档模拟导入已完成

docs/conf.py
中添加以下行:

autodoc_mock_imports = ['sip', 'PyQt5', 'PyQt5.QtGui', 'PyQt5.QtCore', 'PyQt5.QtWidgets']
然后,用一行创建一个docs/requirements.txt

sphinx>=1.7.5
并在readthedocs项目中声明
docs/requirements.txt
管理>高级设置>要求文件


幸运的是,这并没有绕过setup.py,它只是添加了sphinx-1.7.5版本要求。

避免多重继承肯定会在模仿PyQt时消除问题。不确定这是否是经过一番斗争后考虑的唯一解决方案,因为对于模拟类来说,
isclass
是错误的,所以装饰程序而不是多重继承允许使用
autodoc\u mock\u imports
。不幸的是,sphinx模拟了从PyQt5继承的所有类,它们的文档丢失了。这又回到了最初的问题:是否有可能让readthedocs通过
XDG_RUNTIME_DIR
并使用
xvfb run
?我找不到任何证据表明
xvfb
甚至可以在构建环境中使用,即使您设法传递了该环境变量。几乎没有办法绕过对PyQt的嘲笑。您希望从PyQt文档生成什么?据我所知,斯芬克斯实际上没有那么多可供使用的。也许让intersphinx工作就足够了?如果是,请参阅。我设法在您的文档链接中使用基调C++文档中的基类清单使用该帖子中的自定义.vn文件。或者,使用<代码> CONDA < /Cord>帮助?请参阅@three_Pinepples感谢链接(已对问题进行了投票,但尚未看到答案)。这将在以后有用。当前的问题是关于GeOptics类及其文档。添加暂定的4将有望使这一点更清楚。已经打开了一个新的,如果您愿意,可能更适合讨论。
  File ".../geoptics/guis/qt/main.py", line 59, in <module>
    app = QCoreApplication.instance()
AttributeError: type object 'QCoreApplication' has no attribute 'instance'
autodoc_mock_imports = ['sip', 'PyQt5', 'PyQt5.QtGui', 'PyQt5.QtCore', 'PyQt5.QtWidgets']
geoptics.guis.qt.handles.LineHandle.reset_move:1:term not in glossary: move restrictions
autodoc_mock_imports = ['sip', 'PyQt5', 'PyQt5.QtGui', 'PyQt5.QtCore', 'PyQt5.QtWidgets']
sphinx>=1.7.5