|
10 | 10 | from pip._vendor.packaging.utils import canonicalize_name
|
11 | 11 | from pip._vendor.rich import print_json
|
12 | 12 |
|
| 13 | +# Eagerly import self_outdated_check to avoid crashes. Otherwise, |
| 14 | +# this module would be imported *after* pip was replaced, resulting |
| 15 | +# in crashes if the new self_outdated_check module was incompatible |
| 16 | +# with the rest of pip that's already imported, or allowing a |
| 17 | +# wheel to execute arbitrary code on install by replacing |
| 18 | +# self_outdated_check. |
| 19 | +import pip._internal.self_outdated_check # noqa: F401 |
13 | 20 | from pip._internal.cache import WheelCache
|
14 | 21 | from pip._internal.cli import cmdoptions
|
15 | 22 | from pip._internal.cli.cmdoptions import make_target_python
|
@@ -408,12 +415,6 @@ def run(self, options: Values, args: List[str]) -> int:
|
408 | 415 | # If we're not replacing an already installed pip,
|
409 | 416 | # we're not modifying it.
|
410 | 417 | modifying_pip = pip_req.satisfied_by is None
|
411 |
| - if modifying_pip: |
412 |
| - # Eagerly import this module to avoid crashes. Otherwise, this |
413 |
| - # module would be imported *after* pip was replaced, resulting in |
414 |
| - # crashes if the new self_outdated_check module was incompatible |
415 |
| - # with the rest of pip that's already imported. |
416 |
| - import pip._internal.self_outdated_check # noqa: F401 |
417 | 418 | protect_pip_from_modification_on_windows(modifying_pip=modifying_pip)
|
418 | 419 |
|
419 | 420 | reqs_to_build = [
|
|
0 commit comments