Stephen Ross Stephen Ross - 1 year ago 137
Bash Question

Making Sphinx documentation inside of a virtual environment with cron

I have an application development server that is automatically updated every night with a massive shell script that we run with

. The script specifies
at the top of the file and I am not able to change that. The basic purpose of the script is to go through the machine and download the latest code in each of the directories that we list in the script. After all of the repositories are updated, we execute a number of scripts to update the relevant databases using the appropriate virtual environment (Django commands) by calling that virtualenv's python directly.

The issue that I am having is that we have all the necessary Sphinx plugins installed in one of the virtual environments to allow us to build the documentation from the code at the end of the script, but I cannot seem to figure out how to allow the make command to run inside of the virtualenv so that it has access to the proper packages and libraries. I need a way to run the
command inside of the virtual environment and if necessary deactivate that environment afterwards so that the remainder of the script can run.

My current script looks like the below and gives errors on the latter 3 lines, because
does not have workon or deactivate, and because make can't find the sphinx-build.

cd ${_proj_root}/dev/docs
workon dev
make clean && make html

Answer Source

I was able to find the answer to this question here. The error message that is shown when you attempt to build the sphinx documentation from the root is as follows, and leads to the answer that was provided there:

Makefile:12: *** The 'sphinx-build' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the 'sphinx-build' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from Stop.

The full command for anyone looking to build sphinx documentation through a cron when all tools are installed in various virtual environments are listed below. You can find the location of your python and sphinx-build commands by using which while the environment is activated.

make html SPHINXBUILD='<virtualenv-path-to>/python <virtualenv-path-to>/sphinx-build'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download