-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
build/pkgs/pillow
: Allow discovery of libjpeg, upgrade to 10.1.0
#36731
Conversation
build/pkgs/pillow
: Allow discovery of libjpeg, upgrade to 10.1.0
Will pillow still build on a system with no libjpeg? Their docs imply that it won't:
Either required or disabled is better than having it be auto-detected, but if it's going to be required we should probably put it in |
Thanks, I'll check |
I wouldn't like to make it a required dummy package - because as Marc @culler pointed out, it's not available on macOS (without homebrew). |
Code agrees - https://github.com/python-pillow/Pillow/blob/main/setup.py#L810 |
The risk with it being auto-detected is that if you happen to have libjpeg installed temporarily for some unrelated reason, building sage (even with |
Well, that's true for pretty much any use of shared libs from system packages |
Yeah but with a required standard package you can at least avoid the eventual crash with |
That's a fair point. Not sure if a major point, but a fair point. |
We do have a variable |
And note that Pillow autodetects a bunch of other libraries and we are not forbidding that. |
Documentation preview for this PR (built with commit 30d5a7e; changes) is ready! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for implementing this!
LGTM. I've checked it on Ubuntu 22.04, with libjpeg-dev installed as a system package. More precisely, I've built Sage from scratch (starting from a git clone (-> Sage 10.2.rc4) + pull of this branch) and the output of ./configure
is
Checking whether SageMath should install SPKG libjpeg...
checking for libjpeg... yes
configure: will use system package and not install SPKG libjpeg
...
libjpeg: using system package
Then I've checked that running
from PIL import Image
plot(sin(x)).save("fig.png")
img = Image.open("fig.png")
img
in a Jupyter notebook does not trigger any error (contrary to Sage 10.2.rc4), and that the subsequent code
img.convert("RGB").save("fig.jpg")
properly creates a jpeg image file.
I've also checked that the public notebook
https://nbviewer.org/github/sagemanifolds/SageManifolds/blob/master/Notebooks/SM_black_hole_rendering.ipynb
runs without any error.
Thanks for testing! |
In that sense, |
I agree with Dima. The binary wheel is the simplest way to do this.
I wonder whether Sage should perhaps reconsider the policy about never
installing binary wheels into the Sage tree.
- Marc
…On Mon, Nov 20, 2023 at 11:54 AM Dima Pasechnik ***@***.***> wrote:
The risk with it being auto-detected is that if you happen to have libjpeg
installed temporarily for some unrelated reason, building sage (even with
--disable-libjpeg!) will unconditionally build a copy that requires
libjpeg to run. Then when you later remove libjpeg, sage will crash.
In that sense, ./sage --pip install pillow is safer - it will most
probably fetch a binary wheel with everything included.
—
Reply to this email directly, view it on GitHub
<#36731 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ6CP7WAGIW7TJG4U2VA2LYFOKONAVCNFSM6AAAAAA7QRWX6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJZGU2DMNBVHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Note that the included libraries in such binary wheels (built using auditwheel or delocate) may cause library conflicts of the same kind that we otherwise avoid using |
In the case of libjpeg, it is not a dynamic library, but just an ar library
archive. So I am pretty sure that the Pillow python extension is
statically linked with libjpeg.
- Marc
…On Mon, Nov 20, 2023 at 12:15 PM Matthias Köppe ***@***.***> wrote:
In that sense, ./sage --pip install pillow is safer - it will most
probably fetch a binary wheel with everything included.
Note that the included libraries in such binary wheels (built using
auditwheel or delocate) may cause library conflicts of the same kind that
we otherwise avoid using SAGE_SPKG_DEPCHECK files in spkg-configure.m4
Not saying that I'd be overly concerned about this in the particular case
of pillow, but it is something that we do not have control over in general.
—
Reply to this email directly, view it on GitHub
<#36731 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ6CP34ZQJMMOVWK267PVLYFOM2NAVCNFSM6AAAAAA7QRWX6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJZGU3TKNRYHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
That's true about libjpeg (besides that, we know that Pillow is the only package using it!), but the concern extends to the other libraries bundled in the wheel:
|
I think libjpeg is actually pretty high-risk. It's a common system library and lots of math software needs to work with JPEG graphics for e.g. handwriting recognition. You'd have to be able to promise (a) that no other sage dependency would ever want to link to libjpeg, and (b) that the user himself wouldn't want to link a sage program to libjpeg. |
@culler Of course, in preparing your macOS app, you can simply test that the resulting binary works. But for the unattended from-source builds of Sage on user systems, relying on the published wheels from PyPI introduces a lot of potential for mysterious failures. |
On Mon, Nov 20, 2023 at 12:25 PM Michael Orlitzky ***@***.***> wrote:
I think libjpeg is actually pretty high-risk. It's a common system library
and lots of math software needs to work with JPEG graphics for e.g.
handwriting recognition. You'd have to be able to promise (a) that no other
sage dependency would ever want to link to libjpeg, and (b) that the user
himself wouldn't want to link a sage program to libjpeg.
I think that concern applies to dynamic libraries, not to statically linked
libraries. Nonetheless, Matthias seems to be saying that
there are several dynamic libraries packages with the Pillow python
extension. I know that delocate embeds .dylib files into Python packages,
but they put the libraries inside the package (in a directory named
.dylibs) and use relative rpaths. So, if Pillow is using delocate, I don't
actually think that any other parts of sage would be able to find the
dynamic libraries packaged with Pillow.
- Marc
… —
Reply to this email directly, view it on GitHub
<#36731 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ6CP6XGV6WVZMITV4RLKDYFOOC3AVCNFSM6AAAAAA7QRWX6KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJZGU4TAMJUG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I agree with this; but I think the failure mechanism is through possible global symbol clashes of different versions of the same library. |
I'd have to try it to be sure. The issue isn't with finding the bundled libraries but rather with the conflicting symbol names. All of this stuff eventually gets linked into the same executable, so if two libraries (even transitively) provide the same symbols, you can get a conflict if they're not binary-compatible. For example, the bundled pillow .so and the one on my system:
In this case they agree, but... I'd have to try it. (This is why there are different wheels for different libc) |
…grade to 10.1.0 <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> As discussed in https://groups.google.com/g/sage-devel/c/A4nY3bh1oPI @egourgoulhon Here we make`libjpeg` a new "recommended" dummy package with spkg- configure script -- same category as pandoc, ffmpeg, imagemagick, texlive, so it appears in the installation instructions in https://deploy-preview-36731--sagemath- tobias.netlify.app/html/en/installation/source#debian-ubuntu-package- installation (in the 3rd command line for each of the shown package systems). Use of libjpeg can be disabled using `./configure --without-system- libjpeg`. Everything done here would also be necessary if we decided to make libjpeg a normal standard/optional package; that is beyond the scope of this PR. We also refine the "CI Linux incremental" workflow, which determines what packages to uninstall (so that spkg-configure is tested) or to build (important for optional packages), based on changed files. Failures seen in https://github.com/sagemath/sage/actions/runs/691489095 0/job/18813211070?pr=36731#step:4:8 came from the workflow trying to build dummy packages. We suppress these now, as seen in https://github.c om/sagemath/sage/actions/runs/6915792754/job/18815135590?pr=36731#step:4 :8 Tests at https://github.com/mkoeppe/sage/actions/runs/6911535503 (Linux), https://github.com/mkoeppe/sage/actions/runs/6911535500 (macOS) <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36731 Reported by: Matthias Köppe Reviewer(s): Eric Gourgoulhon
Imho this needs more testing than cramming it in at the last minute |
People who use Jupyter seem to consider it a severe regression from the previous release |
And this was tested on the full set of platforms, see ticket description. |
I confirm... |
The issue wasn't just that you can't play with jpegs, but that some other functionality of pillow happens to be broken at the moment if you compile it without jpeg support, right? |
@culler FYI I noticed that libjpeg has a slightly unusual license, that says,
|
Yes indeed. For instance, as reported in https://groups.google.com/g/sage-devel/c/A4nY3bh1oPI/m/0lxrC67HAgAJ, the following code does not manipulate any jpeg but is broken in Sage 10.2.rc4:
For some reason, it yields
while on the user side, we are not asking for any jpeg. |
This is probably fixed in pillow-10.1.0: python-pillow/Pillow#7259 If so, maybe an upgrade to pillow is a less intrusive fix? |
As discussed in https://groups.google.com/g/sage-devel/c/A4nY3bh1oPI @egourgoulhon
Here we make
libjpeg
a new "recommended" dummy package with spkg-configure script -- same category as pandoc, ffmpeg, imagemagick, texlive, so it appears in the installation instructions in https://deploy-preview-36731--sagemath-tobias.netlify.app/html/en/installation/source#debian-ubuntu-package-installation (in the 3rd command line for each of the shown package systems).Use of libjpeg can be disabled using
./configure --without-system-libjpeg
.Everything done here would also be necessary if we decided to make libjpeg a normal standard/optional package; that is beyond the scope of this PR.
We also refine the "CI Linux incremental" workflow, which determines what packages to uninstall (so that spkg-configure is tested) or to build (important for optional packages), based on changed files. Failures seen in https://github.com/sagemath/sage/actions/runs/6914890950/job/18813211070?pr=36731#step:4:8 came from the workflow trying to build dummy packages. We suppress these now, as seen in https://github.com/sagemath/sage/actions/runs/6915792754/job/18815135590?pr=36731#step:4:8
Tests at https://github.com/mkoeppe/sage/actions/runs/6911535503 (Linux), https://github.com/mkoeppe/sage/actions/runs/6911535500 (macOS)
📝 Checklist
⌛ Dependencies