使用Sphinx的`BuildDoc`在`setup.py`上。

huangapple go评论59阅读模式
英文:

Using Sphinx's `BuildDoc` on `setup.py`

问题

Here's the translated content:

我正在接手一个Python项目,其中在 setup.py 脚本中有以下内容:

from sphinx.setup_command import BuildDoc

commands["build_sphinx"] = BuildDoc
cmd_opts["build_sphinx"] = {
    "project": ("setup.py", NAME),
    "version": ("setup.py", about["__version__"]),
    "release": ("setup.py", about["__version__"]),
    "source_dir": ("setup.py", "docs"),
}

这是要传递给 setuptoolssetup() 函数的一部分。
现在我遇到了导入错误,因为找不到这个模块。
Sphinx 文档中我们可以看到:

# this is only necessary when not using setuptools/distribute
from sphinx.setup_command import BuildDoc

http://code.nabla.net/doc/sphinx/api/sphinx/setup_command/sphinx.setup_command.BuildDoc.html

所以我的问题是,我是否可以从其他地方导入这个 BuildDoc,还是应该像文档建议的那样以另一种方式使用 setuptools,如果是这样,我该如何做?

我还将在项目中添加 Poetry,如果有与 Sphinx 配合使用的 "Poetry with Sphinx" 方案,我可能会选择使用它。

我尝试寻找 BuildDoc 的导入方式。

我现在了解到 Sphinx 7.0.0 中已弃用了与 setuptools 的集成,是否仍然有一种集成的方法?

英文:

I am picking up a Python project that has the following in a setup.py script:

from sphinx.setup_command import BuildDoc

commands["build_sphinx"] = BuildDoc
cmd_opts["build_sphinx"] = {
    "project": ("setup.py", NAME),
    "version": ("setup.py", about["__version__"]),
    "release": ("setup.py", about["__version__"]),
    "source_dir": ("setup.py", "docs"),
}

And this is to pass to setup() from setuptools.
Now this gives me an import error, since it can't find the module.
From the Sphinx documentation we have:

# this is only necessary when not using setuptools/distribute
from sphinx.setup_command import BuildDoc

http://code.nabla.net/doc/sphinx/api/sphinx/setup_command/sphinx.setup_command.BuildDoc.html

So my question is if I can import this BuildDoc from somewhere, or should I just use setuptools in another way like suggested by the docs, and if so how do I do it?

I will also add Poetry in the project, so if there is a "Poetry with Sphinx thing", I might want that instead.

I tried looking for the BuildDoc import.

I now get that Sphinx integration with setuptools was deprecated in Sphinx 7.0.0, is there a way to integrate still?

答案1

得分: 0

BuildDoc是命令行sphinx-build的Python对应版本。我通过完全摆脱setuptools,并在makefile中添加以下内容来解决这个问题: poetry run sphinx-build。就像sinoroc提到的那样!谢谢。

英文:

BuildDoc was a python counterpart of the command line sphinx-build.
I solved this by getting rid of the setuptools at all, and just add in the makefile:

poetry run sphinx-build

Just like sinoroc mentionend! Thanks

huangapple
  • 本文由 发表于 2023年5月11日 18:50:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76226813.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定