Skip to content

Split the pip self-version check to get info before run#13923

Merged
notatallshaw merged 4 commits into
pypa:mainfrom
notatallshaw:self-check-before-install
Apr 25, 2026
Merged

Split the pip self-version check to get info before run#13923
notatallshaw merged 4 commits into
pypa:mainfrom
notatallshaw:self-check-before-install

Conversation

@notatallshaw

Copy link
Copy Markdown
Member

This means that everything that needs lazily importing is done before installation happens, while still not importing the network stack for uninstall and list (#12637)

@notatallshaw notatallshaw force-pushed the self-check-before-install branch from 0ee71fd to 946120b Compare April 21, 2026 00:24
Comment thread src/pip/_internal/self_outdated_check.py
Comment thread src/pip/_internal/self_outdated_check.py Outdated
Comment thread src/pip/_internal/self_outdated_check.py Outdated
@notatallshaw

Copy link
Copy Markdown
Member Author

Thanks @ichard26 , I believe I've addressed all your issues. Thanks for catching the dead code, I'd tried a few different approaches and apparently hadn't done a thorough enough clean up.

@sbidoul

sbidoul commented Apr 24, 2026

Copy link
Copy Markdown
Member

I won't have time to review this before the release. Do you still want it in 26.1? How risky is it?

@notatallshaw

notatallshaw commented Apr 24, 2026

Copy link
Copy Markdown
Member Author

Do you still want it in 26.1?

Yes.

How risky is it?

Touching the self update check code has historically reared unexpected issue. I've done my absolute best to validate all the issues we've seen in the past (different upgrade/downgrade paths).

Frankly though, if this PR is considered too risky I think we should disable the self update check, at least for 26.1, it's a one-line change.

@ichard26

Copy link
Copy Markdown
Member

How risky is it?

Given the core logic is wrapped defensively in a try except, I think it'll be fine...?

I tested how it'd handle non-standard indices and an no/bad internet connection and it seemed fine.

Also, the last issue we had with the self check involved pip replacing itself. Given we're now blocking it from running whenever a pip requirement is given eliminates that class of issues.

@notatallshaw

Copy link
Copy Markdown
Member Author

I did an extra pass on validating this doesn't create any new errors, I did find some existing bugs which I will put on my to do list as a follow up, but nothing new.

@notatallshaw notatallshaw merged commit b369bfc into pypa:main Apr 25, 2026
62 of 71 checks passed
@westurner

Copy link
Copy Markdown
  1. Add an env argument way to skip the pip update check?
    • Should there be - or is there already - an env argument way to skip this update check?
      • yes; there should be a way
        • use cases
          • closed-loop, self-hosted
          • third-party index servers only
          • python -m ensurepip

            Note: This module does not access the internet. All of the components needed to bootstrap pip are included as internal parts of the package.
            https://docs.python.org/3/library/ensurepip.html

  2. Update the ensurepip copy of pip

@notatallshaw

Copy link
Copy Markdown
Member Author

Do you have a specific issue? If so please open a new issue.

PIP_DISABLE_PIP_VERSION_CHECK=1 should work to disable pips version check.

@westurner

Copy link
Copy Markdown

Does the copy of pip that ships with Python need to be updated too?

@ichard26

Copy link
Copy Markdown
Member

Yes, but that will be occur at a future date. #13795 will contain the most up to date details.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants