Skip to content

Deprecate imports when installation has started#13829

Open
notatallshaw wants to merge 8 commits intopypa:mainfrom
notatallshaw:disable-imports
Open

Deprecate imports when installation has started#13829
notatallshaw wants to merge 8 commits intopypa:mainfrom
notatallshaw:disable-imports

Conversation

@notatallshaw
Copy link
Member

@notatallshaw notatallshaw commented Feb 28, 2026

Towards #13828

Uses the addaudithook approach to what was suggested in the DPO thread on the problems with globally disabling PEP 810 style lazy imports, but had to be expanded a little as various nuances where found while testing.

@notatallshaw
Copy link
Member Author

notatallshaw commented Feb 28, 2026

This approach has a reasonable chance of breaking tools which manipulate pip such as pip-tools, and possibly redistributions of pip. If we agree this is the correct approach we should contact Linux distributions and known tools that are coupled to the internals of pip and see what could be done to make it less likely to break or give configuration options.

@notatallshaw notatallshaw changed the title Prevent imports when installation has started Deprecate imports when installation has started Mar 6, 2026
@notatallshaw
Copy link
Member Author

This approach has a reasonable chance of breaking tools which manipulate pip

I've taken the approach I discuss in #13828 (comment) and turned this into a depreciation which makes it significantly safer to roll out.

@ichard26
Copy link
Member

ichard26 commented Mar 7, 2026

This is 100% a drive-by review since I have zero free time, but FWIW, if we're going with a warning initially, I'd want the call stack to be printed (or a truncated one, at least) so we can easily identify where these imports are happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants