Skip to content

Include the pip-tools version in the header of pip-compiled requirements.txt files #2247

@jayaddison

Description

@jayaddison

What's the problem this feature will solve?

It can be useful to replicate the pip-compile environment previously used to autogenerate a requirements.txt file. In particular: re-using the same version of pip-compile is likely to minimise the effect of any other local changes applied.

To phrase that conversely: when people attempt to regenerate a requirements.txt file using a much more recent version of pip-tools, it's likely that the output will include extraneous differences that may make it more difficult to notice any unrelated/unexpected changes.

It is currently not readily apparent from the contents of a pip-compile'd requirements.txt file what version of pip-tools was used to compile it.

An optional header can be added, but it contains only the major/minor Python version used, but not the pip-tools version.

Describe the solution you'd like

I'd like to suggest adding the pip-tools version to the header output when the --header option is provided to pip-compile.

As a real-world example, to support some commentary in #2245 I'd like to try replicating the docs/requirements.txt file used in this repository. It is non-trivial for me to figure out what version of pip-tools was used, and that makes it more difficult for me to respond in a timely and accurate manner.

The version number could be the same one produced by pip-compile --version -- e.g. the 7.5.1.dev42+dirty below:

$ pip-compile --version
pip-compile, version 7.5.1.dev42+dirty

Alternative Solutions

Add pip-tools to pyproject.toml and suggest/require that developers use this version when updating autogenerated files.

This could be supported by a continuous integration check that notifies when the compiled requirements.txt content diverges from the version committed to the source repository.

Additional context

Somewhat similar to #2168, except that that issue suggests adding a timestamp; I think that could be useful in some circumstances, but for the use case here I would prefer a version number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions