From 537e632e4e70b7776c885a6efb4838ac5dd6b87b Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:32:46 +0200 Subject: [PATCH] FIX: do not lock RTD environment if no `uv.lock` --- .../check_dev_files/readthedocs.py | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/compwa_policy/check_dev_files/readthedocs.py b/src/compwa_policy/check_dev_files/readthedocs.py index dc0dc206..d31e5706 100644 --- a/src/compwa_policy/check_dev_files/readthedocs.py +++ b/src/compwa_policy/check_dev_files/readthedocs.py @@ -12,6 +12,7 @@ from compwa_policy.errors import PrecommitError from compwa_policy.utilities import CONFIG_PATH, get_nested_dict +from compwa_policy.utilities.match import git_ls_files from compwa_policy.utilities.pyproject import get_constraints_file from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml @@ -192,18 +193,24 @@ def _update_build_step_for_pixi(config: ReadTheDocs) -> None: def _update_build_step_for_uv(config: ReadTheDocs) -> None: + new_command = "export UV_LINK_MODE=copy" + if "uv.lock" in set(git_ls_files(untracked=True)): + new_command += dedent(R""" + uv run --extra doc --locked --with tox \ + tox -e doc + """) + else: + new_command += dedent(R""" + uv run --extra doc --with tox \ + tox -e doc + """) + new_command += dedent(R""" + mkdir -p $READTHEDOCS_OUTPUT + mv docs/_build/html $READTHEDOCS_OUTPUT + """).strip() __update_build_step( config, - new_command=dedent(R""" - export UV_LINK_MODE=copy - uv run \ - --extra doc \ - --locked \ - --with tox \ - tox -e doc - mkdir -p $READTHEDOCS_OUTPUT - mv docs/_build/html $READTHEDOCS_OUTPUT - """).strip(), + new_command, search_function=lambda command: ( "python3 -m sphinx" in command or "sphinx-build" in command