The loader code in PIL/_webp.py
(which is called by the PIL/WebPImagePlugin.py
looks like this:
def __bootstrap__(): global __bootstrap__, __loader__, __file__ import imp, pkg_resources __file__ = pkg_resources.resource_filename(__name__, '_webp.pyd') __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__()
And we just can't import pkg_resources
and its gazillions of dependencies, so the import fails.
I've successfully tested this hardcoded workaround (after copying the _webp.pyd
by hand to the installation directory:
def __bootstrap__(): global __bootstrap__, __loader__, __file__ print("bootstrap() file=%s" % __file__) print("bootstrap() name=%s" % __name__) import imp try: import pkg_resources __file__ = pkg_resources.resource_filename(__name__, '_webp.pyd') print("bootstrap() pkg_resources file=%s" % __file__) except: __file__ = "C:\\Program Files\\Xpra\\_webp.pyd" print("no pkg_resources, trying from %s" % __file__) __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__()
Here's a cleaner workaround:
def __bootstrap__(): global __bootstrap__, __loader__, __file__ print("bootstrap() file=%s" % __file__) print("bootstrap() name=%s" % __name__) import imp try: import pkg_resources __file__ = pkg_resources.resource_filename(__name__, '_webp.pyd') print("bootstrap() pkg_resources file=%s" % __file__) except: import sys, os.path for p in sys.path: f = os.path.join(p, "_webp.pyd") print("testing %s" % f) if os.path.exists(f): __file__ = f print("no pkg_resources, trying from %s" % __file__) __loader__ = None; del __bootstrap__, __loader__ imp.load_dynamic(__name__,__file__) __bootstrap__()
Turns out that we can just force include the webp plugin (r8922) and py2exe does everything for us!
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/833