From d944bd4155a839f9bd4fa537ba152b3f0bd0c1d9 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 15 Nov 2024 09:29:44 -0500 Subject: [PATCH] chore(rtd): Speed up doc build with uv --- readthedocs.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/readthedocs.yml b/readthedocs.yml index 5611c59505..a825e05224 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -1,12 +1,30 @@ version: 2 build: - os: ubuntu-22.04 + os: ubuntu-lts-latest apt_packages: - jq tools: - python: "3.11" + python: latest jobs: + # The *_create_environment and post_install steps replace RTD's virtual environment + # steps with uv, a much faster alternative to virtualenv+pip. + pre_create_environment: + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest + # Turn `python -m virtualenv` into `python -c pass` + - truncate --size 0 $( dirname $( uv python find ) )/../lib/python3*/site-packages/virtualenv/__main__.py + post_create_environment: + - uv venv $READTHEDOCS_VIRTUALENV_PATH + # Turn `python -m pip` into `python -c pass` + - truncate --size 0 $( ls -d $READTHEDOCS_VIRTUALENV_PATH/lib/python3* )/site-packages/pip.py + # post_install replaces the top-level {python: {install: [{requirements: requirements.txt}]}} + post_install: + # Use a cache dir in the same mount to halve the install time + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install --cache-dir $READTHEDOCS_VIRTUALENV_PATH/../../uv_cache -r docs/requirements.txt + # Normal pre-build step to inject schema.json into the source directory + # so schema.json is hosted alongside the specification documents pre_build: - bst -v export --output src/schema.json - tools/no-bad-schema-paths.sh src/schema.json # README.md might need fixing @@ -14,7 +32,3 @@ build: mkdocs: configuration: mkdocs.yml fail_on_warning: true - -python: - install: - - requirements: requirements.txt