cftime icon indicating copy to clipboard operation
cftime copied to clipboard

1.6.0: sphinx warning `WARNING: autodoc: failed to import module 'cftime'`

Open kloczek opened this issue 3 years ago • 5 comments

I'm trying to build cftime documentation and I see that sphinx shows one warning

+ /usr/bin/sphinx-build -n -T -b man docs build/sphinx/man
Running Sphinx v4.5.0
making output directory... done
loading intersphinx inventory from https://docs.python.org/objects.inv...
intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.inv
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] installing
WARNING: autodoc: failed to import module 'cftime'; the following exception was raised:
No module named 'cftime'
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-cftime.3 { installing api } done
build succeeded, 1 warning.

I've been trying to solve that by using below patch but even that does not work

--- a/docs/conf.py~     2022-03-03 14:36:00.000000000 +0000
+++ b/docs/conf.py      2022-04-15 07:55:28.662466239 +0000
@@ -12,9 +12,9 @@
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #
-# import os
-# import sys
-# sys.path.insert(0, os.path.abspath('.'))
+import os
+import sys
+sys.path.append(os.path.abspath('../src'))


 # -- Project information -----------------------------------------------------

kloczek avatar Apr 15 '22 08:04 kloczek

does "make html" work for you? That's the only thing that is tested right now.

jswhit avatar Apr 15 '22 13:04 jswhit

This has nothing to do witj output format because sphins cannot find location of the input module

[tkloczko@devel-g2v cftime-1.6.0rel]$ /usr/bin/sphinx-build -n -T -b html docs build/sphinx/html
Running Sphinx v4.5.0
making output directory... done
loading intersphinx inventory from https://docs.python.org/objects.inv...
intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.inv
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] installing
WARNING: autodoc: failed to import module 'cftime'; the following exception was raised:
No module named 'cftime'
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] installing
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

kloczek avatar Apr 15 '22 13:04 kloczek

Looks like something went wrong with your install then. Can you import cftime from the python interpreter?

jswhit avatar Apr 17 '22 13:04 jswhit

That part of the log is from rpm package buil log. In that kind of situations module is not isntalled and whole process is done from non-root acount. In that kind of process there are few steps

  • build:
    • python3 -sBm build -w --no-isolation
    • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
    • build documentation
  • install:
    • install .whl file in </install/prefix>
    • install man page in </install/prefix>
  • testing:
    • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

So as you see that patch is necessary to have such process sucessfull.

kloczek avatar Apr 17 '22 13:04 kloczek

FYI most of the modules (probably +90%) already have such adaptations in copy.py files.

kloczek avatar Apr 17 '22 13:04 kloczek