I am trying to use PlantUML in my Sphinx project hosted on ReadTheDocs. I want to know how to specify the version of PlantUML to install because it's currently installing an older version, which doesn't have the latest PlantUML features I want.
I currently have PlantUML diagrams working by adding these to my Sphinx extensions
(in conf.py):
"sphinx.ext.graphviz",
"sphinxcontrib.plantuml",
And I am installing PlantUML as part of my ReadTheDocs configuration (in .readthedocs.yaml):
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- plantuml
sphinx:
configuration: wiki/conf.py
fail_on_warning: true
python:
install:
- requirements: wiki/requirements.txt
But when it builds on ReadTheDocs I see it's installing PlantUML version 1.2020.2, which is quite old:
$ apt-get update --assume-yes --quiet
$ apt-get install --assume-yes --quiet -- plantuml
...
Get:46 http://archive.ubuntu.com/ubuntu jammy/universe amd64 plantuml all 1:1.2020.2+ds-1 [8035 kB]
...
Selecting previously unselected package plantuml.
Preparing to unpack .../45-plantuml_1%3a1.2020.2+ds-1_all.deb ...
Unpacking plantuml (1:1.2020.2+ds-1) ...
...
Setting up plantuml (1:1.2020.2+ds-1) ...
...
done.
You can create a wiki/scripts/pre_install.sh
#!/bin/bash
# Stop and exit on error
set -euox pipefail
# Check for required tools
java -version
dot -V
# This folder is on PATH and does not require sudo
# Download latest plantuml.jar from github
curl -o ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml.jar -L https://github.com/plantuml/plantuml/releases/download/v1.2024.3/plantuml-1.2024.3.jar
# Create an executable script for plantuml
printf '#!/bin/bash\nexec java -Djava.awt.headless=true -jar ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml.jar "$@"' > ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml
chmod +x ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml
# Check plantuml version
plantuml -version
and then update your .readthedocs.yaml
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- default-jre
- graphviz
jobs:
pre_install:
- bash wiki/scripts/pre_install.sh
sphinx:
configuration: wiki/conf.py
fail_on_warning: true
python:
install:
- requirements: wiki/requirements.txt