Building documentation raises error 'no module named sage_autodoc'
I am trying to figure out how to get sphinx to build documentation for a package. I have tried several sample packages from github and always get the same error, so it must be a problem in my personal installation.
For instance, following the instructions to build documentation of these packages:
- github.com/sagemath/sage_sample/tree/master
- github.com/mmasdeu/sage_package_template/tree/master
- github.com/BlackHolePerturbationToolkit/kerrgeodesic_gw/tree/master
I'm eventually asked to run
$ make doc
on the main folder of the package, to which I get
sphinx-build -b html -d build/doctrees source build/html
Running Sphinx v4.3.2
Extension error:
Could not import extension sage_autodoc (exception: No module named 'sage_autodoc')
make: *** [Makefile:53: html] Error 2
I have SageMath version 9.5, Release Date: 2022-01-30, using Python 3.10.12. I have checked that there is indeed a module called sage_autodoc in my local installation, in the file sage_docbuild/ext/sage_autodoc.py
.
For some reason, sage is not acknowledging it. Does anyone know how to solve this?
Just a guess: if you run
sage --buildsh
first, that will start a new shell with various environment variables set, and those variables might help Python/Sphinx find the appropriate modules. You could trysage --buildsh -c "make doc"
.I do run
make doc
withinsage -sh
for building the documentation of my packageI have cloned your package (slabbe) and tried
make doc
as well assage --buildsh -c "make doc"
. Both times the error still persists, but is different:Extension error: Could not import extension sage_autodoc (exception: cannot import name 'RemovedInSphinx80Warning' from 'sphinx.deprecation' (/usr/lib/python3/dist-packages/sphinx/deprecation.py))
Maybe version 4.3.2 of Sphinx is too old and you need to upgrade?
Or maybe the Sphinx installed within SageMath 9.5 is not built with optional extensions like
sage_autodoc
? Is this the sagemath-9.5 available on Debian?Since I posted the question, I completely uninstalled and reinstalled SageMath in my computer, to make sure that everything was setup as in the latest stable release. That hasn't solved the problem. I believe Sphinx would have been updated to the most recent version while doing that.
I'm not on Debian, I'm on Ubuntu 22.04.4. The current version of SageMath was installed following the instructions from github:
github.com/sagemath/sage/blob/develop/README.md
You may need to adapt the autogenerated
conf.py
file. For instance, here is what I wrote in lines 25-28: