Skip to content

Conversation

@ianthomas23
Copy link
Collaborator

This is a correction to the code that moves backend handling to Matplotlib, which came to light during the review of matplotlib/matplotlib#27948. The GUI framework of macOSX is called osx in IPython but macosx in Matplotlib.

It would be possible to allow passing a GUI framework of osx to Matplotlib and internally converting it to macosx, but the reverse direction is problematic as we would like the answer to be osx if we are using IPython and macosx if using pure Matplotlib. Therefore the simplest solution is to do the translation in IPython. It is not ideal as we want to minimise such Matplotlib-related implementation details in IPython, but the changes here are small and simple and hence I think they are acceptable.

There are two new private functions _convert_gui_to_matplotlib and _convert_gui_from_matplotlib to do the required checking and conversion, and these are called whenever a GUI framework name is passed to or from Matplotlib. There are only 3 places in the code where this is currently required.

Inevitably this comes to light just after the release of IPython 8.24.0! But it is not a problem for end users until the next Matplotlib release which contains matplotlib/matplotlib#27948. If that occurs really quickly (sometime in May?) perhaps we could release an IPython 8.24.1 just beforehand, otherwise the usual planned release at the end of next month would be fine.

@ianthomas23
Copy link
Collaborator Author

I've pushed a couple more commits to this to be consistent with changes made following review of the corrresponding Matplotlib PR. They are:

  • There are no explicit qt6agg and qt6cairo backends in Matplotlib, they are the unversioned qtagg and qtcairo instead.
  • When requesting a "headless" GUI framework, Matplotlib returns None rather than "headless".

@Carreau Carreau added this to the 8.25 milestone May 6, 2024
@Carreau
Copy link
Member

Carreau commented May 6, 2024

Thanks !

@Carreau Carreau merged commit 85bb530 into ipython:main May 6, 2024
@ianthomas23 ianthomas23 deleted the osx_macosx_gui_framework branch May 7, 2024 07:15
@ianthomas23
Copy link
Collaborator Author

The Matplotlib PR for this (matplotlib/matplotlib#27948) has been merged and will be in 3.9.0 which is at RC stage and should be released later this month. There are no other changes required at either end for this all to work as intended, once that and IPython 8.25 are released.

Carreau added a commit that referenced this pull request May 7, 2024
This updates the docs in line with the recent changes to move Matplotlib
backend resolution to Matplotlib itself. In passing I have removed
references to things that have definitely disappeared from Matplotlib
(such as `qt4`), and I've added a comment about when
`_matplotlib_manages_backends()` can be removed in future.

This, along with #14420, should conclude the backend transition.
Carreau added a commit that referenced this pull request Jun 25, 2024
This is a bug that I discovered whilst dealing with
matplotlib/matplotlib#28332. The change here is in
`TerminalInteractiveShell.enable_gui` which needs to convert a gui of
`macosx` from Matplotlib into `osx` in IPython. It reuses the converter
function created in #14420.

I've added a test that uses `enable_gui` and raises an exception before
this PR but passes with it.

The remainder of the changes are formatting changes from `pre-commit`.
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