astral-sh / uv

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

Add lock files for inline script metadata #7483

Open ketozhang opened 3 weeks ago

ketozhang commented 3 weeks ago

https://docs.astral.sh/uv/guides/scripts/#declaring-script-dependencies

I find inline script metadata difficult to adopt because it forces all my users to run the script with a compatible runner (e.g., uv or pipx). For backwards compatibility with pip install method, a tradition requirements file is still necessary.

$ uv pip compile --script example.py -o requirements.txt
# Users without uv
$ pip install -r requirements.txt
$ python example.py

Other use cases involve, not relying on uv's venv management. For example, you have many scripts with inline metadata, but want 1 venv to be compatible with all:

$ uv pip compile --scripts scripts/*.py -o requirements.txt

My title could be more specific, but I am opening it up to uv run example.py automatically creating a uv.lock. This could be a future once we have a standard lock file.

charliermarsh commented 2 weeks ago

There's some overlap with #6318, though I guess you're also asking here for a way to install the script dependencies outside of uv. I'm not sure if we're likely to support that since it kind of defeats the purpose of the PEP.

ketozhang commented 2 weeks ago

There's significant overlap with #6318 that I am OK with closing this as duplicate.

I feel it---I have the same sentiment back when the PEP was designed. After the fact, I now wish the PEP went further with addressing reproducibility (no good ideas until we have a standard lock file)