How to make sphinx look for modules in virtualenv while building html?

前端 未结 3 1209
梦如初夏
梦如初夏 2021-01-30 10:42

I want to build html docs using a virtualenv instead of the native environment on my machine.

I\'ve entered the virtualenv but when I run make html I get e

3条回答
  •  灰色年华
    2021-01-30 11:20

    I had the same problem, but I couldn't use the accepted solution because I didn't use the Makefile. I was calling sphinx-build from within a custom python build file. What I really wanted to do was to call sphinx-build with the exact same environment that I was calling my python build script with. Fiddling with paths was too complicated and error prone, so I ended up with what seems to me like an elegant solution, which is to "manually" load the console script entry point and call it:

    from pkg_resources import load_entry_point
    cmd = load_entry_point('Sphinx', 'console_scripts', 'sphinx-build')
    cmd(['sphinx-build', basepath, destpath])
    

提交回复
热议问题