4

我想使用 readthedocs.org 为我的项目生成文档(包括使用 autodoc 自动生成的文档。但是,我的项目使用 Python 3.5 语法 ( asyncand await),它看起来无法处理。构建成功,虽然我得到了很多这样的错误:

/home/docs/checkouts/readthedocs.org/user_builds/sparrow/checkouts/latest/docs/source/entity.rst:176: WARNING: autodoc: failed to import module 'sparrow.entity'; the following exception was raised:
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/sparrow/envs/latest/local/lib/python3.4/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
    __import__(self.modname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sparrow/checkouts/latest/sparrow/__init__.py", line 26, in <module>
    from .model import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/sparrow/checkouts/latest/sparrow/model.py", line 37
    async def install(self):

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

4

3 回答 3

4

其他答案有点过时了,因为现在 Readthedocs.org 确实支持 Python 3.5 和 3.6。要使用它,必须配置readthedocs.yml. 可以在此处找到有关此的文档:http: //docs.readthedocs.io/en/latest/yaml-config.html

使 Readthedocs.org 使用 Python 3.5 的最小示例是:

build:
    image: latest

python:
    version: 3.5

如果您有任何依赖项,可以通过requirements.txt文件或通过setup.py. 例如,如果你想使用setup.py你只需告诉 Readthedocs.org 安装你的包:

build:
    image: latest

python:
    version: 3.5
    setup_py_install: true
于 2018-01-30T15:44:01.693 回答
2

感谢 Dietrich 的回答(我没有找到 github 问题,这很糟糕),我发现了一个关于conda的非常有价值的提示。它看起来有点像 virtualenv,但它可以自己安装二进制文件和 python 版本。

我可以通过将两个文件添加到我的 github 存储库中来使其工作,都在根目录中(尽管 environment.yml 可以放在其他地方)。如果有人想获得一个基本的 conda 环境,您可以使用它,而不必自己安装 conda。

阅读文档.yml

conda:
    file: environment.yml

环境.yml

name: py35
dependencies:
- openssl=1.0.2g=0
- pip=8.1.1=py35_0
- python=3.5.1=0
- readline=6.2=2
- setuptools=20.3=py35_0
- sqlite=3.9.2=0
- tk=8.5.18=0
- wheel=0.29.0=py35_0
- xz=5.0.5=1
- zlib=1.2.8=0
- pip:
  - momoko>=2.2.3
  - psycopg2>=2.6.1
  - tornado==4.3

通常你可以在 requirements.txt 文件中添加需求,然后通过 pip 安装。使用 conda 时,您必须在 environment.yml 文件中列出它们,就像我对 momoko、psycopg2 和 tornado 所做的那样。

于 2016-03-22T00:41:12.497 回答
1

Readthedocs.org 目前不支持 Python 3.5,请参阅issue 1990: python 3.5 support for build system

于 2016-03-21T23:44:55.213 回答