Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kloczek opened this issue Apr 15, 2022 · 5 comments
Open

Comments

@kloczek
Copy link

kloczek commented Apr 15, 2022

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 -----------------------------------------------------
@jswhit
Copy link
Collaborator

jswhit commented Apr 15, 2022

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

@kloczek
Copy link
Author

kloczek commented Apr 15, 2022

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.

@jswhit
Copy link
Collaborator

jswhit commented Apr 17, 2022

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

@kloczek
Copy link
Author

kloczek commented Apr 17, 2022

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
Copy link
Author

kloczek commented Apr 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants