Skip to content

More concise uv example #11946

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

Closed
wants to merge 3 commits into from
Closed

More concise uv example #11946

wants to merge 3 commits into from

Conversation

lengau
Copy link

@lengau lengau commented Jan 23, 2025

This provides a more succinct uv example using uv sync. It also has the benefit of not requiring overriding of any build steps.


📚 Documentation previews 📚

This provides a more succinct uv example using `uv sync`
@lengau lengau requested a review from a team as a code owner January 23, 2025 00:50
@lengau lengau requested a review from ericholscher January 23, 2025 00:50
Comment on lines -476 to -479
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.
Copy link
Member

Choose a reason for hiding this comment

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

Seems this is removing the build step completely?

Copy link
Author

Choose a reason for hiding this comment

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

It's no longer overriding the build step because it doesn't need to, since uv is installing things in the regular RTD virtualenv. Here's a screenshot of a real run of this (from canonical/starbase#330):

image

Copy link
Author

Choose a reason for hiding this comment

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

And the full build log: starbase-build-log.txt

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

This example still isn't really a common uv use case though? I think we want to show people how to use uv in a way that makes it really clear what the steps are?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure why this wouldn't be a common uv case? This is using uv's project management and lock file, where the previous example uses uv as a drop-in replacement for pip but doesn't use uv.lock This also matches quite well to the poetry steps above the example.

@lengau lengau requested a review from ericholscher January 25, 2025 22:40
@coroa
Copy link

coroa commented Mar 11, 2025

Fully agree with @lengau here. While the uv example currently in the docs, relies on requirements.txt superseeded by dependencies and dependency-groups in pyproject.toml and breaks all output formats except for html, this one is able to just really on the default build steps making it a lot more flexible.

I did propose essentially the same strategy in #12033, only moving the package installation fully into create_environment. As in #12033, i would only add the --add-extras flag to uv sync.

@ericholscher
Copy link
Member

The problem with this update is that it doesn't explain uv sync. It presumably is depending on other files/state somewhere, which should be noted.

@coroa
Copy link

coroa commented Mar 12, 2025

The problem with this update is that it doesn't explain uv sync. It presumably is depending on other files/state somewhere, which should be noted.

Hmm, uv sync is implicit in uv run, so the current setup is pulling in the same state, which is pyproject.toml and uv.lock (if the latter exists).

All of that is explained in good detail in the uv projects guide .

The lesser known trick here is that setting the environment variable UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" makes uv update the environment where the default readthedocs build steps expect it, so that it integrates seamlessly. That is the exact same strategy used for poetry as described at https://docs.readthedocs.com/platform/stable/build-customization.html#id14 .

But anyway, I hear that by adding a bit of context around this update, you think it would become acceptable. I'll propose something then.

@ericholscher
Copy link
Member

But anyway, I hear that by adding a bit of context around this update, you think it would become acceptable. I'll propose something then.

Yea, I think explaining the code snippet and what state is required to make it work is great. We have requirements and other things mentioned a lot in our docs, but don't have uv specific stuff anywhere. It can definitely be a link out to the uv docs tho, but at least something.

@lengau
Copy link
Author

lengau commented Mar 21, 2025

Superseded by #12064

@lengau lengau closed this Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants