'Import and setup a Sphinx extension module. No-op if called twice.'

def setup_extension(self, extension):

    if (extension in self._extensions):
        return
    try:
        mod = __import__(extension, None, None, ['setup'])
    except ImportError as err:
        raise ExtensionError(('Could    not    import    extension    %s' % extension), err)
    if (not hasattr(mod, 'setup')):
        self.warn(('extension    %r    has    no    setup()    function;    is    it    really    a    Sphinx    extension    module?' % extension))
    else:
        mod.setup(self)
    self._extensions[extension] = mod
