ipython / ipykernel

IPython Kernel for Jupyter
https://ipykernel.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
649 stars 367 forks source link

Fix use of "%matplotlib osx" #1237

Closed ianthomas23 closed 5 months ago

ianthomas23 commented 6 months ago

Fixes #1124 which is that the use of %matplotlib osx crashes ipykernel and downstream libraries whereas ipython is fine.

The fix is to specify the argtypes of each objc_msgSend call just before the call. This is consistent with how ipython successfully handles it. I have tested this manually using spyder and jupyter console, qtconsole, lab and nbclassic: using ipykernel 6.29.4 (the latest release) they all crash, using this branch they all work as expected.

This PR is opened against the 6.x branch rather than main as issue #1235 means it is not possible to test any matplotlib GUI loops on main. It would be good to get this into a release (6.29.5?) as soon as possible and not have to wait for #1235 and the other AnyIO fallout issues to be fixed beforehand. This PR will therefore need to be forward ported to main.

There is no explicit test for this as you need to actually render a macos window to trigger the failure, and this is not an easy thing to do on headless CI. Essentially this functionality sits in the grey area between matplotlib and ipython/ipykernel/jupyter rather than in any individual project.

ivanlen commented 5 months ago

Do you have an ETA to release this fix?

ianthomas23 commented 5 months ago

@ivanlen It looks like this could be in a release in about 2 weeks time.

blink1073 commented 4 months ago

@ianthomas23 can you please try running this workflow with the default settings? https://github.com/ipython/ipykernel/actions/workflows/publish-release.yml. It should finalize the draft release I made over the weekend.

ianthomas23 commented 4 months ago

@blink1073 Done! Workflow run is https://github.com/ipython/ipykernel/actions/runs/9745716039/job/26894339146 and 6.29.5 is up on PyPI.

blink1073 commented 4 months ago

Woohoo!

ianthomas23 commented 4 months ago

Thanks for your help!