Skip to content

Commit 34fbe69

Browse files
authored
Merge pull request #9692 from EricCousineau-TRI/issue-8726-2
2 parents 831f32e + 81896cf commit 34fbe69

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

docs/html/cli/pip_install.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,13 @@ Examples
10001000
10011001
py -m pip install --upgrade SomePackage
10021002
1003+
.. note::
1004+
1005+
This will guarantee an update to ``SomePackage`` as it is a direct
1006+
requirement, and possibly upgrade dependencies if their installed
1007+
versions do not meet the minimum requirements of ``SomePackage``.
1008+
Any non-requisite updates of its dependencies (indirect requirements)
1009+
will be affected by the ``--upgrade-strategy`` command.
10031010

10041011
#. Install a local project in "editable" mode. See the section on :ref:`Editable Installs <editable-installs>`.
10051012

docs/html/development/architecture/upgrade-options.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ candidate.
3030
``--upgrade-strategy``
3131

3232
This option affects which packages are allowed to be installed. It is only
33-
relevant if ``--upgrade`` is specified. The base behaviour is to allow
33+
relevant if ``--upgrade`` is specified (except for the ``to-satisfy-only``
34+
option mentioned below). The base behaviour is to allow
3435
packages specified on pip's command line to be upgraded. This option controls
3536
what *other* packages can be upgraded:
3637

@@ -43,9 +44,15 @@ what *other* packages can be upgraded:
4344
pip command or a requirement file (i.e, they are direct requirements), or
4445
an upgraded parent needs a later version of the dependency than is
4546
currently installed.
46-
* ``to-satisfy-only`` (**undocumented**) - packages are not upgraded (not
47-
even direct requirements) unless the currently installed version fails to
48-
satisfy a requirement (either explicitly specified or a dependency).
47+
* ``to-satisfy-only`` (**undocumented, please avoid**) - packages are not
48+
upgraded (not even direct requirements) unless the currently installed
49+
version fails to satisfy a requirement (either explicitly specified or a
50+
dependency).
51+
52+
* This is actually the "default" upgrade strategy when ``--upgrade`` is
53+
*not set*, i.e. ``pip install AlreadyInstalled`` and
54+
``pip install --upgrade --upgrade-strategy=to-satisfy-only AlreadyInstalled``
55+
yield the same behavior.
4956

5057
``--force-reinstall``
5158

docs/html/user_guide.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,21 @@ strategies supported:
825825
The default strategy is ``only-if-needed``. This was changed in pip 10.0 due to
826826
the breaking nature of ``eager`` when upgrading conflicting dependencies.
827827

828+
It is important to note that ``--upgrade`` affects *direct requirements* (e.g.
829+
those specified on the command-line or via a requirements file) while
830+
``--upgrade-strategy`` affects *indirect requirements* (dependencies of direct
831+
requirements).
832+
833+
As an example, say ``SomePackage`` has a dependency, ``SomeDependency``, and
834+
both of them are already installed but are not the latest avaialable versions:
835+
836+
- ``pip install SomePackage``: will not upgrade the existing ``SomePackage`` or
837+
``SomeDependency``.
838+
- ``pip install --upgrade SomePackage``: will upgrade ``SomePackage``, but not
839+
``SomeDependency`` (unless a minimum requirement is not met).
840+
- ``pip install --upgrade SomePackage --upgrade-strategy=eager``: upgrades both
841+
``SomePackage`` and ``SomeDependency``.
842+
828843
As an historic note, an earlier "fix" for getting the ``only-if-needed``
829844
behaviour was:
830845

news/9692.doc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Describe ``--upgrade-strategy`` and direct requirements explicitly; add a brief
2+
example.

0 commit comments

Comments
 (0)