File tree 1 file changed +11
-3
lines changed 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,18 @@ def _get_available_interactive_backends():
81
81
elif env ["MPLBACKEND" ] == 'macosx' and os .environ .get ('TF_BUILD' ):
82
82
reason = "macosx backend fails on Azure"
83
83
elif env ["MPLBACKEND" ].startswith ('gtk' ):
84
- import gi # type: ignore
84
+ try :
85
+ import gi # type: ignore
86
+ except ImportError :
87
+ # Though we check that `gi` exists above, it is possible that its
88
+ # C-level dependencies are not available, and then it still raises an
89
+ # `ImportError`, so guard against that.
90
+ available_gtk_versions = []
91
+ else :
92
+ gi_repo = gi .Repository .get_default ()
93
+ available_gtk_versions = gi_repo .enumerate_versions ('Gtk' )
85
94
version = env ["MPLBACKEND" ][3 ]
86
- repo = gi .Repository .get_default ()
87
- if f'{ version } .0' not in repo .enumerate_versions ('Gtk' ):
95
+ if f'{ version } .0' not in available_gtk_versions :
88
96
reason = "no usable GTK bindings"
89
97
marks = []
90
98
if reason :
You can’t perform that action at this time.
0 commit comments