sphinxでうまいこと仮想環境を見てくれない時

Sphinxで上手いこと仮想環境を見てないと

1The 'sphinx-build' command was not found. Make sure you have Sphinx
2installed, then set the SPHINXBUILD environment variable to point
3to the full path of the 'sphinx-build' executable. Alternatively you
4may add the Sphinx directory to PATH.
5
6If you don't have Sphinx installed, grab it from
7http://sphinx-doc.org/

とか出てきたりして困る
エラーの通りSPHINXBUILDにsphinx-buildのパスを入れても良いがこれだと仮想環境使ってる時困るので

Winならmake.batに

1if "%SPHINXBUILD%" == "" (
2	set SPHINXBUILD=python -m sphinx
3)

Linux系列ならMakefileに

1SPHINXBUILD   = python -m sphinx

と書いておくと仮想環境に切り替わっていればPythonのパスは仮想環境へ向いてるはずなので良い感じに動く