diff --git a/Makefile b/Makefile index 38b476628..e0e6ecd73 100644 --- a/Makefile +++ b/Makefile @@ -3,23 +3,26 @@ # You can set these variables from the command line. PYTHON = python3 +VENVDIR = ./venv +BUILDDIR = _build SPHINXOPTS = -SPHINXBUILD = ./venv/bin/sphinx-build +SPHINXBUILD = $(VENVDIR)/bin/sphinx-build PAPER = -BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp \ +.PHONY: help venv clean html dirhtml singlehtml pickle json htmlhelp qthelp \ devhelp epub latex latexpdf text man changes linkcheck doctest htmlview check help: @echo "Please use \`make ' where is one of" + @echo " venv to create a venv with necessary tools" @echo " html to make standalone HTML files" @echo " htmlview to open the index page built by the html target in your browser" + @echo " clean to remove the venv and build files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @@ -37,13 +40,22 @@ help: @echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " check to run a check for frequent markup errors" -clean: +clean: clean-venv -rm -rf $(BUILDDIR)/* +clean-venv: + rm -rf $(VENVDIR) + venv: - $(PYTHON) -m venv venv - ./venv/bin/python3 -m pip install --upgrade pip - ./venv/bin/python3 -m pip install -r requirements.txt + @if [ -d $(VENVDIR) ] ; then \ + echo "venv already exists."; \ + echo "To recreate it, remove it first with \`make clean-venv'."; \ + else \ + $(PYTHON) -m venv $(VENVDIR); \ + $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ + $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ + echo "The venv has been created in the $(VENVDIR) directory"; \ + fi html: venv $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html