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

Support updating the uv lockfile for individual PEP 723 scripts #33591

Open
rarkins opened this issue Jan 13, 2025 Discussed in #33590 · 0 comments
Open

Support updating the uv lockfile for individual PEP 723 scripts #33591

rarkins opened this issue Jan 13, 2025 Discussed in #33590 · 0 comments
Labels
manager:pep723 Related to the pep723 manager module priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)

Comments

@rarkins
Copy link
Collaborator

rarkins commented Jan 13, 2025

Discussed in #33590

Originally posted by mjpieters January 13, 2025

Tell us more.

Hi!

renovate already supports updating dependencies in a PEP 723 comment block in python scripts.

uv has since added support for a lockfile for such scripts:

% cat <<EOF > example.py
# /// script
# dependencies = [
#   "requests<3",
#   "rich",
# ]
# ///

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])
EOF
% uv lock --script example.py
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.12`.
Resolved 9 packages in 496ms
% ls -1
example.py
example.py.lock
% head example.py.lock
version = 1
requires-python = ">=3.12"

[manifest]
requirements = [
    { name = "requests", specifier = "<3" },
    { name = "rich" },
]

[[package]]

The lockfile has the same name as the script file with .lock appended, and the file format is the same as that for regular project lockfiles (uv.lock).

The feature is new in uv 0.5.17:

This release includes support for generating lockfiles from scripts based on inline metadata, as defined in PEP 723.

By default, scripts remain unlocked, and must be locked explicitly with uv lock --script /path/to/script.py, which will generate a lockfile adjacent to the script (e.g., script.py.lock). Once generated, the lockfile will be respected (and updated, if necessary) across uv run --script, uv add --script, and uv remove --script invocations.

This release also includes support for uv export --script and uv tree --script. Both commands support PEP 723 scripts with and without accompanying lockfiles.

It would be great if renovate could update these lockfiles.

@rarkins rarkins added type:feature Feature (new functionality) priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others manager:pep723 Related to the pep723 manager module and removed type:feature Feature (new functionality) labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
manager:pep723 Related to the pep723 manager module priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)
Projects
None yet
Development

No branches or pull requests

1 participant