astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.72k stars 774 forks source link

Feature request: option to not update `uv.lock` file #5185

Closed kdeldycke closed 4 months ago

kdeldycke commented 4 months ago

Using the latest uv:

$ uv --version
uv 0.2.26 (fe403576c 2024-07-17)

Description

When I call a uv run, I get the uv.lock updated and kept in sync automatically. I would like to have a way to tell uv to not change the uv.lock file at all.

Context

I am maintaining several Python-based CLI. To keep their Sphinx-based documentation up-to-date, I rely on a reusable GitHub workflow that calls uv run sphinx-apidoc.

The problem is that while uv run sphinx-apidoc is doing its job producing auto-generated documentation, that way of invoking it is also updating the uv.lock file at the base of the checked-out repository.

And because my last step of the workflow is creating a PR with all local changes, I end up with a noisy PR that not only contain the changes from sphinx-apidoc, but also unexpected updates in uv.lock file.

My quick fix was to add an extra step to force its exclusion:

      - name: Reset uv.lock
        # Exclude `uv.lock` file which might be auto-updated by calls to `uv run`.
        run: |
          git checkout -- uv.lock

And that's how I end up with a clean PR with only the changes produced by sphinx-apidoc.

Now I just wonder if it might be a good idea to add a new option to uv, to let it restrain itself and keep uv.lock as it found it. Something like uv run --no-lock-update.

Discussion

If keeping the uv.lock in sync is good for everyday run, the reason I do not need that behavior in automated workflows is because I already have another dedicated job to keep it in sync.

charliermarsh commented 4 months ago

We have these options on uv sync already, I meant to add them to uv run.

charliermarsh commented 4 months ago

I'll likely ship this today.

kdeldycke commented 4 months ago

Oh wow, that was fast! Thanks @charliermarsh for the quick addition! 🤗