canonical / sphinx-docs-starter-pack

A documentation starter-pack
https://canonical-starter-pack.readthedocs-hosted.com/
Other
13 stars 35 forks source link

If `make install` fails, it should run again #195

Open ru-fu opened 5 months ago

ru-fu commented 5 months ago

If make install fails and you fix the reason for the failure and run it again, it says there's nothing to do:

root@run-pa11y:~/starter-pack-copy# make install
python3 .sphinx/build_requirements.py
python3 -c "import venv" || sudo apt install python3-venv
... setting up virtualenv
python3 -m venv .sphinx/venv
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python3.8-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/root/starter-pack-copy/.sphinx/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

make: *** [Makefile:48: .sphinx/venv] Error 1
root@run-pa11y:~/starter-pack-copy# apt install python3.8-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
[...]
Setting up python3.8-venv (3.8.10-0ubuntu1~20.04.9) ...
root@run-pa11y:~/starter-pack-copy# make install
make: Nothing to be done for 'install'.

So you need to run make clean first.

Not sure what is the best way around this - make install could either check if the venv actually exists, or we could say that if make install is run explicitly, it should always run, even if there is an installation already.

dviererbe commented 5 months ago

make install could either check if the venv actually exists

issue: Make already checks if venv exists, but interestingly the venv directory will be created even if the python*-venv dependency is missing and therefore does nothing on a subsequent run. The directory is not even empty, so there is no easy check to determine if venv is corrupted (to my knowledge) :/

or we could say that if make install is run explicitly, it should always run, even if there is an installation already.

issue: Always running clean would be pretty resource intensive, because it would also always be executed for make run, make html, make epub, etc., and therefore increases time spent on during the iteration cycle. I think it can also be considered an anti-pattern to the declarative Make paradigm.

thought: Maybe we could use the special target .DELETE_ON_ERROR for the install target. See: https://www.gnu.org/software/make/manual/html_node/Special-Targets.html

note: I will do some testing and report back.