Skip to content

Conversation

@lukegb
Copy link
Contributor

@lukegb lukegb commented Feb 1, 2022

In some cases, the Tk library may have been directly compiled in or bundled into the main executable by the time Pillow runs, in which case __file__ isn't available (nor would it make sense to use, anyway).

If __file__ is missing, then set the library path to None and rely on our Tk loader being able to find the function pointers within the main binary - we know we probably have it because we've managed to import it already.

In some cases, the Tk library may have been directly compiled in or
bundled into the main executable by the time Pillow runs, in which case
__file__ isn't available (nor would it make sense to use, anyway).

If __file__ is missing, then set the library path to None and rely on
our Tk loader being able to find the function pointers within the main
binary - we know we probably have it because we've managed to import it
already.
@radarhere
Copy link
Member

In some cases

Could you go into a bit more detail about when this occurs?

@lukegb
Copy link
Contributor Author

lukegb commented Feb 2, 2022

Sure! For deployment purposes, at work we use Bazel to build the Python interpreter alongside all the C/C++ native code for any extensions which are depended on and building them into a single binary, and then attach all the Python code as a zip to the end of the binary.

This allows for a very simple deployment mechanism, since you have only one file you need to care about for deployment purposes (no virtualenvs, etc.), and without relying on the system Python interpreter. In theory it also gives better LTO opportunities because the calls to the Python interpreter API from extension modules can be seen and potentially inlined.

@radarhere radarhere merged commit a4bb0ec into python-pillow:main Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants