Skip to content

Commit

Permalink
Merge pull request #12684 from ichard26/fix-pip-downgrade
Browse files Browse the repository at this point in the history
Eagerly import `self_outdated_check` when modifying pip
  • Loading branch information
pradyunsg committed May 9, 2024
2 parents a7369ba + b2a3986 commit 912da19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions news/12675.bugfix.rst
@@ -0,0 +1,2 @@
Eagerly import the self version check logic to avoid crashes while upgrading
or downgrading pip at the same time.
6 changes: 6 additions & 0 deletions src/pip/_internal/commands/install.py
Expand Up @@ -406,6 +406,12 @@ def run(self, options: Values, args: List[str]) -> int:
# If we're not replacing an already installed pip,
# we're not modifying it.
modifying_pip = pip_req.satisfied_by is None
if modifying_pip:
# Eagerly import this module to avoid crashes. Otherwise, this
# module would be imported *after* pip was replaced, resulting in
# crashes if the new self_outdated_check module was incompatible
# with the rest of pip that's already imported.
import pip._internal.self_outdated_check # noqa: F401
protect_pip_from_modification_on_windows(modifying_pip=modifying_pip)

reqs_to_build = [
Expand Down

0 comments on commit 912da19

Please sign in to comment.