Skip to content

More concise uv example with docs #12064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions docs/user/build-customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -450,33 +450,41 @@ Take a look at the following example:
Install dependencies with ``uv``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Projects can use `uv <https://github.com/astral-sh/uv/>`__,
to install Python dependencies, usually reducing the time taken to install compared to pip.
Take a look at the following example:
Projects managed with `uv <https://github.com/astral-sh/uv/>`__, can install `uv` with asdf,
and then rely on it to set up the environment and install the python project and its dependencies
where readthedocs' own build steps expect it by setting the ``UV_PROJECT_ENVIRONMENT`` variable,
usually reducing the time taken to install compared to pip.
Comment on lines +453 to +456
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but I think it would be valuable to break up into a few smaller sentences.


The following examples assumes uv's project managed was used as described in its
`projects concept <https://docs.astral.sh/uv/concepts/projects/>`__. As an introduction
refer to its `Working on projects guide <https://docs.astral.sh/uv/guides/projects/>`__.
The ``doc`` dependency group which should is pulled in during the ``uv sync`` step (if additional
extras are required they can be added with the `--extra attribute <https://docs.astral.sh/uv/concepts/projects/sync/#syncing-optional-dependencies>`__).

If a ``uv.lock`` file exists it is respected.

.. code-block:: yaml

:caption: .readthedocs.yaml

version: 2

sphinx:
configuration: docs/conf.py

build:
os: ubuntu-24.04
tools:
python: "3.13"
jobs:
create_environment:
post_system_dependencies:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv venv
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- uv pip install -r requirements.txt
build:
html:
- uv run sphinx-build -T -b html docs $READTHEDOCS_OUTPUT/html

MkDocs projects could use ``NO_COLOR=1 uv run mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html`` instead.
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs

Update Conda version
~~~~~~~~~~~~~~~~~~~~
Expand Down