3

编写的 python 工具awscli-bastion具有以下由 cookiecutter 构建的目录结构

.
├── awscli_bastion
│   ├── __init__.py
│   ├── cache.py
│   ├── cli.py
│   ├── credentials.py
│   ├── minimal.py
│   └── sts.py
├── docs
│   ├── Makefile
│   ├── _build
│   ├── ...
│   ├── conf.py
│   ├── ...
├── setup.py
├── .readthedocs.yml
│   ...

其中 setup.py 包含以下内容:

requirements = [ 'Click>=6.0', 'boto3>=1.5.0', 'awscli>=1.13.0', 'humanize>=0.5.1' ]

其中 conf.py 包含以下内容:

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

import awscli_bastion

和 .readthedocs.yml 包含:

# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
  configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
#  configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
  version: 3.7

当 sphinx 在本地构建时,所有模块功能都会自动记录。

在此处输入图像描述

当我在 readthedoc.io 上构建时,它可以成功导入所有 awscli_bastion 包模块,但它无法自动记录模块功能,因为它在导入时失败。

WARNING: autodoc: failed to import module 'cache' from module 'awscli_bastion'; the following exception was raised:
No module named 'dateutil'
WARNING: autodoc: failed to import module 'cli' from module 'awscli_bastion'; the following exception was raised:
No module named 'botocore'
WARNING: autodoc: failed to import module 'credentials' from module 'awscli_bastion'; the following exception was raised:
No module named 'botocore'
WARNING: autodoc: failed to import module 'minimal' from module 'awscli_bastion'; the following exception was raised:
No module named 'boto3'
WARNING: autodoc: failed to import module 'sts' from module 'awscli_bastion'; the following exception was raised:
No module named 'botocore'

https://readthedocs.org/api/v2/build/9667746.txt

这是在https://awscli-bastion.readthedocs.io/en/latest/awscli_bastion.html上呈现的内容

在此处输入图像描述

为什么 readthedoc.io virtualenv 没有安装 setup.py 中定义的依赖项?

4

1 回答 1

1

好的,我希望能够通过创建包含以下内容的docs/requirements.txt文件来安装依赖项:

Click>=6.0
boto3>=1.5.0
awscli>=1.13.0
humanize>=0.5.1
docutils>=0.15.2

然后在 .readthedocs.yml 中引用它

python:
  version: 3.7
  install:
    - requirements: docs/requirements.txt

参考 setup.py 的要求会更理想,这样我就不必定义它们两次。

于 2019-09-17T04:47:14.143 回答