From 0b4a349173bd6c1cc1c50b4a933ac2c933102021 Mon Sep 17 00:00:00 2001 From: Lewis <15088984+lewis-wf@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:52:22 +0000 Subject: [PATCH] Update scripts docs with package indexes (#11443) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary The [current scripts docs page](https://docs.astral.sh/uv/guides/scripts/) doesn't include detail on how to use a custom package index when setting up a script. I believe this might be because it didn't use to work (see #6688 ) but it now does (thanks for that, by the way! 😄) Given it's a useful feature, I suggest adding a quick example to the scripts page, with the details of authentication, etc. left to the main `indexes.md` doc. I'd also suggests that this closes #6688, though it doesn't actually add that feature - that appears to have already been done :) ## Test Plan No testing is needed, I think! --------- Co-authored-by: Zanie Blue --- docs/guides/scripts.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/guides/scripts.md b/docs/guides/scripts.md index 1dbf91b3a..ab13dec59 100644 --- a/docs/guides/scripts.md +++ b/docs/guides/scripts.md @@ -217,6 +217,25 @@ print(Point) is not installed — see the documentation on [Python versions](../concepts/python-versions.md) for more details. +## Using alternative package indexes + +If you wish to use an alternative [package index](../configuration/indexes.md) to resolve +dependencies, you can provide the index with the `--index` option: + +```console +$ uv add --index "https://example.com/simple" --script example.py 'requests<3' 'rich' +``` + +This will include the package data in the inline metadata: + +```python +# [[tool.uv.index]] +# url = "https://example.com/simple" +``` + +If you require authentication to access the package index, then please refer to the +[package index](../configuration/indexes.md) documentation. + ## Locking dependencies uv supports locking dependencies for PEP 723 scripts using the `uv.lock` file format. Unlike with