Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import distutils only if needed, but sooner #11324

Merged
merged 1 commit into from
Jul 30, 2022
Merged

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Jul 29, 2022

fixes #11319

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did it too well. 😆

We should really add tests for this mess.

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how we can test this; just try to do pip install -U in a temporary virtual environment?

@sbidoul
Copy link
Member Author

sbidoul commented Jul 30, 2022

This only happens in user site because in uninstall we have

if dist.in_usersite:
bin_dir = get_bin_user()
else:
bin_dir = get_bin_prefix()

and get_bin_user() does not import _distutils (so it is not in memory when installing later) while get_bin_prefix() does.

@sbidoul
Copy link
Member Author

sbidoul commented Jul 30, 2022

To test this we need to install pip in user site, then force-reinstall it from a wheel. I've no idea how to do that in our test suite.

@sbidoul sbidoul merged commit 56dcb7f into pypa:main Jul 30, 2022
@sbidoul sbidoul deleted the better-11103 branch July 30, 2022 09:02
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

upgrade from 22.2 to 22.2.1. fails with ImportError for name '_distutils'
3 participants