astral-sh / uv

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

`uv run` without generating `uv.lock` file #8329

Closed patrick-kidger closed 21 hours ago

patrick-kidger commented 21 hours ago

We'd like to use uv, whilst using requirements.txt as the lockfile format.

(Right now this is important for interopability with other tools: until PEP751 becomes reality then requirements.txt is the de-facto common denominator understood by everyone.)

For that purpose we're currently using uv run --with-requirements requirements.txt <rest of command here>. However, this seems to generate a spurious uv.lock file.

Given that --with-requirements involves explicitly opting in to using a different lockfile, then I'm not sure if this is unexpected behaviour and I'm raising a bug report, or if this is something there should be a flag to toggle and I'm raising a feature request!

zanieb commented 21 hours ago

uv run --with-requirements includes those requirements on top of your project ones. Maybe you want to set managed = false in your project?

https://docs.astral.sh/uv/reference/settings/#managed

patrick-kidger commented 21 hours ago

Ah, I didn't know that existed! Okay, giving it a try: my understanding is that to use requirements.txt as the lock file instead, then I should replace uv run <foo> with

uv pip compile pyproject.toml -o requirements.txt &>/dev/null && uv run --with-requirements requirements.txt <foo>

Thanks for your help :)