fix: use alternate scheme for importing multipart by henryiii · Pull Request #168 · Kludex/python-multipart

Colab users don't know they need to invalidate importlib caches, and the help in colab doesn't tell them they need to. And invalidating the import caches doesn't work, since the problem is the .pth file is run at startup, and is not related to import caches. Remember, the problem can be seen with:

!pip install python-multipart==0.0.13
import multipart

The .pth files are run when the notebook kernel starts, which doesn't have any dependencies at all (Colab doesn't give you a way to pre-install deps). Then you install the package (which adds the .pth file), but it never gets a chance to run. Adding an importlib.invalidate_caches() in-between has no effect.

FWIW, this works, because it does exactly what the .pth file would have done:

!pip install python-multipart==0.0.13
import _python_multipart_loader
import multipart

But no one would know to do that.