What is a reliable way to specify a minimum pip version?

145 views Asked by At

What is a reliable way to specify the minimum required pip version in a project that uses pyproject.toml?

Is it:

[build-system]
requires = ["setuptools>=64.0", "pip>=x.y"]
build-backend = "setuptools.build_meta"

or should one put it into requirements-dev.txt?

or simply a pip install --upgrade pip, before installing the dev-requirements?

The background of the question is, I'm running tests across all main operating systems and Python versions. Some combinations fail because the pip version on the host machine is too old.

1

There are 1 answers

0
sinoroc On BEST ANSWER

As far as I know this is not possible.

Note that pip maintainers only ever support the latest version of pip. It is assumed that everyone is responsible for keeping their pip up-to-date. So yes the correct way is to update pip before doing anything with pip.

The latest version of the pip is the only supported version, previous versions should be considered unsupported. Users are encouraged to make regular updates to their version of pip in order to remain supported.

-- https://pip.pypa.io/en/latest/development/release-process/#supported-versions

If your goal is to reproduce one specific behavior of a whole tool chain or workflow (including pip's behavior) in your test processes (CI/CD pipelines?), then feel free to pin pip to a specific version explicitly (python -m pip install pip==X.Y.Z).

Of course, be also conscious that pip's maintainers are not perfect and each new release of pip is likely to contain some bugs. It has happened in the past that a new release of pip "broke" many a project's CI/CD pipeline. So pinning pip's version to a known but recent version is probably the best balance, with the inconvenient that this chosen pinned version itself must be updated once in a while (maybe at the earliest a few days after each new release of pip to avoid the possible new bugs).