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
How to tell at run time whether libjpeg-turbo version of libjpeg is used? #3492
Comments
Would you be able to test PR #3493, and see if that works for you? That PR would let you use the following code to test for libjpegturbo - from PIL import features
features.check_feature('libjpegturbo') |
Thank you for the PR, @radarhere! It needs more work with the right includes. It works (returns True) only with this patch on top of your PR:
Otherwise In I don't know enough about this codebase to tell whether this might break something else. Also may I ask to rename the new "feature" to Thank you. |
Variable name bikeshedding time! The existing features use underscores, let's be consistent with our existing API. And the others are all features = {
"webp_anim": ("PIL._webp", 'HAVE_WEBPANIM'),
"webp_mux": ("PIL._webp", 'HAVE_WEBPMUX'),
"transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY"),
"raqm": ("PIL._imagingft", "HAVE_RAQM"),
} So I'd probably go for: "libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO"), |
Looking good, @radarhere. My only concern was of what would happen if after compiling Pillow, someone swaps in an identical version of libjpeg.so.X.Y.Z (i.e. |
And I wrote a little code snippet to use this feature (perhaps it's doc worthy) and I assume it'll be available in 5.4.0.
packaging's version is probably a better choice as it correctly deals with
|
tl;dr:
Is there some way to accomplish:
PIL.Image.libjpeg_turbo_is_enabled()
?The full story:
Is there a way to tell from a pre-built Pillow whether it was built against
libjpeg-turbo
or not?This is assuming that all I have is
libjpeg.so.X.X
and no way to tell where it came from.I see there is a symbol in the library:
but I don't know how to access its value from python.
If there is a way to tell the same from from shell using
ldd
/nm
or other linker tools, it'd do too.The intention is to be able to tell a user at run-time to re-build Pillow after installing
libjpeg-turbo
to gain speed. The problem is that It's not enough to build Pillow againstlibjpeg-turbo
. Given how conda/pip dependencies work, a new prebuilt package ofPillow
could get swapped in as a dependency for some other package and the user won't know that they now run a less efficientPillow
unless they watch closely any install/update logs.Currently the only solution I can think of (in conda env) is to take the output of:
which wold give me something like:
And then to try to match it to:
which may work. There is a problem with this approach
It's very likely that conda is going to reinstall
jpeg
since many packages depend on it, and when it does, there is going to be 2 libjpeg libs.And now I can no longer tell which is which, since I can no longer tell which of the two Pillow will load at run time. Well, I can go one step further and check /proc//maps to get the library, but it's getting more and more convoluted. And I won't even know how to do the same on non-linux platform. And this is just for the conda setup, for pip setup it'd be something else.
Also what happens if
libjpeg-turbo
andlibjpeg
are the same version?Perhaps there is an easier way? Any chance to have
PIL.Image.libjpeg_turbo_is_enabled()
?Thank you.
The text was updated successfully, but these errors were encountered: