Building documentation raises error 'no module named sage_autodoc'

asked 0 years ago

alvgutcac gravatar image

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?

Preview: (hide)

Comments

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 try sage --buildsh -c "make doc".

John Palmieri gravatar imageJohn Palmieri ( 0 years ago )

I do run make doc within sage -sh for building the documentation of my package

Sébastien gravatar imageSébastien ( 0 years ago )

I have cloned your package (slabbe) and tried make doc as well as sage --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))

alvgutcac gravatar imagealvgutcac ( 0 years ago )

Maybe version 4.3.2 of Sphinx is too old and you need to upgrade?

John Palmieri gravatar imageJohn Palmieri ( 0 years ago )

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?

Sébastien gravatar imageSébastien ( 0 years ago )

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

alvgutcac gravatar imagealvgutcac ( 0 years ago )

You may need to adapt the autogenerated conf.py file. For instance, here is what I wrote in lines 25-28:

sys.path.append(os.path.join(SAGE_SRC, "sage_docbuild", "ext"))          # after 9.3

# NOTE: The path to sage_autodoc.py file changed
# from src/sage_setup/docbuild/ext/ to src/sage_docbuild/ext/
# in https://trac.sagemath.org/ticket/30010 merged in Sagemath-9.3
Sébastien gravatar imageSébastien ( 0 years ago )