`make html` fails in `salt/returners/mongo_return.py`
With the current tip of the develop branch (fc9b244) on Ubuntu 15.04:
$ make -C doc html
No need to update translations. Skipping...
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.3.1
loading translations [en]... done
loading pickled environment... done
[autosummary] generating autosummary for: contents-1.rst, contents-2.rst, contents-3.rst, contents-4.rst, contents.rst, faq.rst, glossary.rst, index.rst, ref/auth/all/index.rst, ref/auth/all/salt.auth.auto.rst, ..., topics/tutorials/walkthrough.rst, topics/tutorials/walkthrough_macosx.rst, topics/tutorials/writing_tests.rst, topics/virt/disk.rst, topics/virt/index.rst, topics/virt/nic.rst, topics/windows/index.rst, topics/windows/windows-package-manager.rst, topics/windows/windows-specific-behavior.rst, topics/yaml/index.rst
Failed to import 'salt.modules.cytest': no module named salt.modules.cytest
Failed to import 'salt.states.libvirt': no module named salt.states.libvirt
Exception occurred:
File "/home/rhansen/salt/salt/returners/mongo_return.py", line 60, in <module>
version = '.'.join(version.split('.')[:2])
TypeError: 'Mock' object has no attribute '__getitem__'
The full traceback has been saved in /tmp/sphinx-err-2Gkv1Q.log, if you want to report the issue to the developers.
Full traceback info:
# Sphinx version: 1.3.1
# Python version: 2.7.9 (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.7.3
# Last messages:
# Loaded extensions:
Traceback (most recent call last):
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 244, in main
opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/application.py", line 188, in __init__
self._init_builder(buildername)
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/application.py", line 250, in _init_builder
self.emit('builder-inited')
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/application.py", line 497, in emit
results.append(callback(self, *args))
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/__init__.py", line 564, in process_generate_options
base_path=app.srcdir)
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 115, in generate_autosummary_docs
items = find_autosummary_in_files(sources)
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 228, in find_autosummary_in_files
filename=filename))
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 326, in find_autosummary_in_lines
current_module, filename=filename))
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/generate.py", line 238, in find_autosummary_in_docstring
real_name, obj, parent, modname = import_by_name(name)
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/__init__.py", line 473, in import_by_name
obj, parent, modname = _import_by_name(prefixed_name)
File "/home/rhansen/salt/local/lib/python2.7/site-packages/sphinx/ext/autosummary/__init__.py", line 502, in _import_by_name
__import__(modname)
File "/home/rhansen/salt/salt/returners/mongo_return.py", line 60, in <module>
version = '.'.join(version.split('.')[:2])
TypeError: 'Mock' object has no attribute '__getitem__'
Unsurprisingly, git bisect shows the problem is with 63153322b9b4ef8d852c8e8a1621a724b8a56ac7.
ping @rallytime @rhealitycheck
Reverting both 63153322b9b4ef8d852c8e8a1621a724b8a56ac7 and e49a6dc449ea7731e433720a557030f28154be9e makes it possible to build the docs again.
That's actually necessary in order for the returner to be compatible with older versions of pymongo. However I'm happy to take that out and simplify my life by just supporting people on 3.0 or newer.
I think it would be better to leave your code in place and figure out a way to unbreak the documentation. But if that's not easy to do, then reverting those commits might be a reasonable temporary solution.
@richardhansen Does #27474 solve this for you? (Note - that fix hasn't been merged forward from 2015.8 to develop yet, but I believe that change will solve your problem.)
Oh! I spoke too soon about the merge forward. One was just merged in with #27531. Is this still a problem with the current HEAD of develop?
Works for me now. Thanks!
:+1:
@rallytime thanks for finding the fix!