astral-sh / uv

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

Header of locked requirements does not include Python version #3588

Open Rogdham opened 6 months ago

Rogdham commented 6 months ago

Hello, I noticed that pip-tools includes the Python version compiled against in the header, while uv does not:

1,6c1,2
< #
< # This file is autogenerated by pip-compile with Python 3.12
< # by the following command:
< #
< #    pip-compile requirements.in
< #
---
> # This file was autogenerated by uv via the following command:
> #    uv pip compile requirements.in -o requirements.txt

As we know, until a platform-agnostic lock file is created, the output depends on the Python version.

Having the version included is useful for caching mechanisms, typically in CI where the venv can be cached based on the hash of the requirements.txt file.

As a workaround for now, we can add the version in UV_CUSTOM_COMPILE_COMMAND.

Results above from pip-tools 7.4.1 / uv 0.1.44.

avilaton commented 4 months ago

@charliermarsh I've proposed a change in dependabot that relies on the tiny piece of string autogenerated by uv to decide if it should use uv pip compile instead of pip-compile. I'm worried about the brittleness of this approach but if we don't have any better ideas, I would like to at least add a test that ensures this doesn't change without warning. I can try adding it if you think that helps.