0

I am trying to generate documentation of some python interface module generated by SWIG on C code. I am using %feature(docstring) directive in SWIG interface files (*.i) as mentioned the post: Sphinx and documenting python from a swigged C++ api

SWIG is generating docstrings in the generated python modules as intended.

But when I am trying to generate documentation out of the SWIG generated python modules it is throwing exception:

/home/imitra/testdoc/doc/test_module.rst:4: WARNING: autodoc: failed to import module u'test_module'; the following exception was raised:
Traceback (most recent call last):
  File "/home/imitra/.local/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 658, in import_object
    __import__(self.modname)
  File "/home/imitra/testdoc/generated/test_module.py", line 3, in <module>
  _test_module = swig_import_helper()
  File "/home/imitra/testdoc/generated/test_module.py", line 25, in swig_import_helper
    return importlib.import_module('_test_module')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _tiger

This happens as Sphinx try to import test_module.py and the SWIG generated code gets executed.

Is there a way around this problem ? I am newbie to both SWIG and Sphinx. Please share your thoughts.

mzjn
  • 48,958
  • 13
  • 128
  • 248
  • This looks like `_tiger` could not be found and imported. Can you import the module? Else work up the stack trace to see where it gets called. – Steve Piercy Dec 14 '17 at 05:58
  • SOLVED: Thanks Steve I missed one *.so file which I wrapped using SWIG to put in sys.path. Sphinx was failing to load the module. – Indrajit Mitra Dec 15 '17 at 05:59

1 Answers1

0

I get a similar error (when building Sphinx) on ReadTheDocs.io as you do when I've forgotten to update my requirements.txt-file. Then RTD doesn't know to install all dependencies.

I don't know much about Sphinx in regards to C++ or SWIG, or if it applies to your issue.

Thomas Fauskanger
  • 2,536
  • 1
  • 27
  • 42