If I have a venv
with black==22.12.0
installed and I run pip install --U black
then pip
will update to the newest version of black. I will see same behavior if black
is listed in a requirements.txt and I run pip install -U -r requirements.txt
. In this case pip eagerly updates if a new version is available.
Now suppose I have a venv
with and editable install created with pip install -e .
from a pyproject.toml
(example below). If this has black==22.12.0
installed and if I then run pip install -U -e .
then black is not updated to the latest version. If I pin in the version of black in pyproject.toml
to say black>=23" then
pip install -U -e .` will update black. In this case pip only updates if the current version does not satisfy the requirements.
I cannot find anything in the docs describing this behavior. Is it intentional or a fault that pip install -U
behaves differently in these two contexts?
Tests are made pip version 23.0.1 and python 3.10.10
[build-system]
requires = ["setuptools>=65.5"]
build-backend = "setuptools.build_meta"
[project]
name = "packaging_example"
version = "0.0.7"
description = "python packaging example"
requires-python = "==3.10"
dependencies = [
"black"
]
[tool.setuptools.packages.find]
where = ["src"]
requirements.txt
file you are explicitly listing (via the file contents) packages to upgrade. Butpyproject.toml
just contains information about the current project's dependencies. If you upgrade the current project, and the existing dependency installations meet the project's requirements even in the new version, then why should the dependencies get upgraded? (And, of course, withpip install -e
, the current project's version number hasn't changed unless you updatedpyproject.toml
.) – Inhuman