Skip to content
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

Simplify instructions for installing dependencies with uv #11655

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

browniebroke
Copy link
Contributor

@browniebroke browniebroke commented Oct 7, 2024

Since the instructions were added in #11322, uv gained a new capability to run uv sync and uv run enabling some simplifications


📚 Documentation previews 📚

@browniebroke browniebroke requested a review from a team as a code owner October 7, 2024 19:12
@browniebroke browniebroke requested a review from agjohnson October 7, 2024 19:12

You can use ``-r docs/requirements.txt``, etc. instead as needed. MkDocs projects could use ``NO_COLOR=1 .venv/bin/mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html`` instead.
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.

Isn't it required the -m here?

Copy link
Contributor Author

@browniebroke browniebroke Oct 7, 2024

Choose a reason for hiding this comment

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

uv run mkdocs tries to run the mkdocs binary, while uv run -m mkdocs tries to run mkdocs as module, and AFAIK both work:

 ➜ uv run -m mkdocs --help
Usage: python -m mkdocs [OPTIONS] COMMAND [ARGS]...

  MkDocs - Project documentation with Markdown.

Options:
  -V, --version         Show the version and exit.
  -q, --quiet           Silence warnings
  -v, --verbose         Enable verbose output
  --color / --no-color  Force enable or disable color and wrapping for the output. Default is auto-detect.
  -h, --help            Show this message and exit.

Commands:
  build      Build the MkDocs documentation.
  get-deps   Show required PyPI packages inferred from plugins in mkdocs.yml.
  gh-deploy  Deploy your documentation to GitHub Pages.
  new        Create a new MkDocs project.
  serve      Run the builtin development server.
 ➜ uv run mkdocs --help 
Usage: mkdocs [OPTIONS] COMMAND [ARGS]...

  MkDocs - Project documentation with Markdown.

Options:
  -V, --version         Show the version and exit.
  -q, --quiet           Silence warnings
  -v, --verbose         Enable verbose output
  --color / --no-color  Force enable or disable color and wrapping for the output. Default is auto-detect.
  -h, --help            Show this message and exit.

Commands:
  build      Build the MkDocs documentation.
  get-deps   Show required PyPI packages inferred from plugins in mkdocs.yml.
  gh-deploy  Deploy your documentation to GitHub Pages.
  new        Create a new MkDocs project.
  serve      Run the builtin development server.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Thanks! I don't have too much experience with uv, but I'm happy to merge this if you already tested it on Read the Docs. Do you have a working example?

@browniebroke
Copy link
Contributor Author

Great question 😄 Yes, we use this in cookiecutter-django: cookiecutter/cookiecutter-django#5440

@humitos humitos merged commit 173d044 into readthedocs:main Oct 8, 2024
3 of 5 checks passed
@browniebroke browniebroke deleted the docs/uv-deps branch October 8, 2024 12:51
@Zethson
Copy link

Zethson commented Oct 25, 2024

I get

Using CPython 3.11.9 interpreter at: /home/docs/.asdf/installs/python/3.11.9/bin/python
Creating virtual environment at: .venv
error: Unable to find lockfile at `uv.lock`. To create a lockfile, run `uv lock` or `uv sync`.

for

uv sync --extra docs --frozen

I assume this requires a lock file?

@browniebroke
Copy link
Contributor Author

I assume this requires a lock file?

Yes, of course

@Zethson
Copy link

Zethson commented Oct 25, 2024

The old instructions don't so I consider this a regression. Not every project (I'd argue very few at the moment) are using uv lockfiles.

@browniebroke
Copy link
Contributor Author

As far as I understand, the uv venv... and uv pip install... were compatibility commands too meet users where they are with bare virtaulenv and pip usages. The modern way is to use the first party commands uv sync, uv run and yes, lockfiles.

I didn't know it was possible to opt-out of lockfile with uv... If you don't want lockfiles, what's the point of uv?

The old instructions don't so I consider this a regression

That's only a documented recommended way, you have to copy the config into your own project. Then you're free to branch it and adapt it however you like, calling that a "regression" a bit of a strong wording IMO 😄 Perhaps add a note after the snippet that this workflow needs a lockfile?

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