Skip to content

Commit 912da19

Browse files
authored
Merge pull request #12684 from ichard26/fix-pip-downgrade
Eagerly import `self_outdated_check` when modifying pip
2 parents a7369ba + b2a3986 commit 912da19

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

news/12675.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Eagerly import the self version check logic to avoid crashes while upgrading
2+
or downgrading pip at the same time.

src/pip/_internal/commands/install.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ def run(self, options: Values, args: List[str]) -> int:
406406
# If we're not replacing an already installed pip,
407407
# we're not modifying it.
408408
modifying_pip = pip_req.satisfied_by is None
409+
if modifying_pip:
410+
# Eagerly import this module to avoid crashes. Otherwise, this
411+
# module would be imported *after* pip was replaced, resulting in
412+
# crashes if the new self_outdated_check module was incompatible
413+
# with the rest of pip that's already imported.
414+
import pip._internal.self_outdated_check # noqa: F401
409415
protect_pip_from_modification_on_windows(modifying_pip=modifying_pip)
410416

411417
reqs_to_build = [

0 commit comments

Comments
 (0)