-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
AssertionError when importing pip before setuptools #3621
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
Comments
Yes. It seems that's the case, and I'm tempted to say that usage is unsupported. The distutils shim intentionally disables the distutils override when it detects that it's being imported by pip. That function references pypa/pip#8761 as the rationale. Thereafter, when setuptools is imported, it checks to ensure that the override was applied, but since it was disabled by the presence of an I also don't think it's wise to use the workaround either. By importing setuptools then pip, you're causing setuptools to get Is there a good reason to "import pip" against the guidance of that project? |
Yes, but not a supported reason. In my case, I need to patch pip. I do so at runtime during Python startup, rather than actually forking the codebase. Until this issue occurred, I did this patching unconditionally (making sure to keep the patching quick to avoid any significant startup overhead). I have just updated this to only patch pip when it is first imported (by attaching a lazy module in It is unusual that one can't import two packages in the same process though. Thank you for providing the links on the history of the underlying reasons - I have one question that wasn't clear from what I read though (please feel free to link to a discussion elsewhere): Why is it that setuptools knows that it needs to have a patched version of distutils, and yet cannot use a (setuptools) namespaced version of distutils? Is there fundamentally some design limitation of distutils that forced this upon you? This issue is fundamentally caused by setuptools calling its patched version In terms of this issue, I am happy in principle to resolve this as a wont-fix - |
Though perhaps not quite the reproducing case you are looking for, as it doesn't include
get-pip
?Dockerfile
form:Incidentally, a workaround is to import setuptools first, and filter warnings if you then want to import
pip
. This looks like:(I care about the latter setuptools because it is something that I don't have full control of in my real-world case)
Originally posted by @pelson in #3439 (comment)
The text was updated successfully, but these errors were encountered: