简体   繁体   中英

Sphinx: “no module named compat”

Our Travis CI tests just started breaking randomly:

https://travis-ci.org/Gallopsled/pwntools/builds/343962397

With the error message:

Could not import extension sphinxcontrib.autoprogram (exception: No module named compat)

It appears that the issue is that one of our Sphinx dependencies relies on deprecated functionality: https://github.com/sphinx-contrib/autoprogram/issues/1

How can I work around this?

We can dynamically re-inject the module and its contents with the code below, by putting it in the Sphinx conf.py :

try:
    import sphinx.util.compat
except ImportError:
    import sys
    import types
    import sphinx.util
    import docutils.parsers.rst
    class compat(types.ModuleType):
        Directive = docutils.parsers.rst.Directive
    sphinx.util.compat = compat('sphinx.util.compat')
    sys.modules['sphinx.util.compat'] = sphinx.util.compat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM