4

The python tool that writing, awscli-bastion, has the following directory structure built by cookiecutter.

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

where the setup.py contains the following:

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

where the conf.py contains the following:

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

import awscli_bastion

and .readthedocs.yml contains:

# .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

When sphinx is built locally, all of the module functions are auto-documented.

enter image description here

When I build on readthedoc.io, it can successfully import all of the awscli_bastion package modules, but it fails to auto-document the module functions because it fails on the imports.

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

this is what is rendered on https://awscli-bastion.readthedocs.io/en/latest/awscli_bastion.html

enter image description here

Why is the readthedoc.io virtualenv not installing the dependencies defined in the setup.py?

mzjn
  • 48,958
  • 13
  • 128
  • 248
aidanmelen
  • 6,194
  • 1
  • 23
  • 24

1 Answers1

2

okay, I want able to get the dependencies to install by creating a docs/requirements.txt file containing the following:

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

and then referencing that in the .readthedocs.yml

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

It would be more ideal to reference the setup.py for the requirements, that way I do not have to define them twice.

aidanmelen
  • 6,194
  • 1
  • 23
  • 24
  • 3
    You can. Put `-e .[docs]` in your `requirements.txt`, assuming you have added a [`docs_extra`](https://github.com/Pylons/pyramid/blob/master/setup.py#L45-L52). [This is what we do for Pyramid](https://github.com/Pylons/pyramid/blob/master/rtd.txt). – Steve Piercy Sep 17 '19 at 17:35
  • Is it possible to use pyproject.toml instead of requirements.txt in some way? – janpeterka Jul 26 '23 at 16:52