Skip to content

Commit

Permalink
Move self_outdated_check import to the top to stop WHL exec on install.
Browse files Browse the repository at this point in the history
Fixes pypa#13079.

Signed-off-by: Caleb Brown <[email protected]>
  • Loading branch information
calebbrown committed Nov 18, 2024
1 parent fe0925b commit d7bdc0d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
)
from pip._internal.wheel_builder import build, should_build_for_install_command

# 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, or allowing a
# wheel to execute arbitrary code on install by replacing
# self_outdated_check.
import pip._internal.self_outdated_check # noqa: F401

logger = getLogger(__name__)


Expand Down Expand Up @@ -408,12 +416,6 @@ 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 d7bdc0d

Please sign in to comment.