Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx fails to import module dependencies

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?

like image 657
aidanmelen Avatar asked Oct 30 '25 18:10

aidanmelen


1 Answers

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.

like image 184
aidanmelen Avatar answered Nov 03 '25 11:11

aidanmelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!