uv icon indicating copy to clipboard operation
uv copied to clipboard

`uv pip compile` requires explicit `-o requirements.txt` unlike `pip-compile`

Open ThiefMaster opened this issue 4 months ago • 3 comments

Not only does this require some repetition on the commandline (specifying both filenames), but it also makes it easy to get the wrong behavior when using e.g. shell redirection instead of -o because it won't take the existing requirements file into account.


With pip-tools I can do this:

pip-compile -q && pip-compile -q requirements.dev.in

and it works great:

  • When I added a new dependency to my requirements[.dev].in, it updates the .txt as expected
  • If I didn't do anything there are no changes to the files since I did not request any upgrades nor is there anything else to change

With uv I now need to do this (twice as long!):

uv pip compile -o requirements.txt requirements.in && uv pip compile -o requirements.dev.txt requirements.dev.in

FYI, all my tests are done on the requirements files of the indico/indico repo.

ThiefMaster avatar Feb 15 '24 21:02 ThiefMaster

I actually went back and forth on this -- I personally don't like this automatic behavior from pip-tools but I might be part of a small minority. @konstin strongly prefers it.

charliermarsh avatar Feb 15 '24 21:02 charliermarsh

How about an uv pip compile --auto that looks for requirements*.{in,txt}, checks if there are dependencies between them (e.g. -c requirements.txt in a requirements.something.in), and then compiles them in the proper order?

This would also be REALLY amazing for upgrades. Imagine just being able to uv compile --auto --upgrade-package somepackage if you want to upgrade that package :)

ThiefMaster avatar Feb 15 '24 21:02 ThiefMaster

I also ran into this -- I actually agree that the pip-compile behavior is worse and wouldn't have done it that way myself, but given it exists and that I suspect most users will be moving from it I'd have likely erred on the side of preserving it. It's probably not a good argument now that uv has been out for a little while though.

In my case given I support both uv and non-uv in my projects' noxfiles at the minute I basically do this.

I do think it's somewhat surprising behavior, so I would perhaps suggest considering mentioning it more prominently (in both the README and uv pip compile --help maybe).

Julian avatar Apr 22 '24 07:04 Julian