Skip to content

Commit 2476177

Browse files
committed
try harder to get the matplotlib version (fixes #448)
1 parent 693895e commit 2476177

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/init.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,21 @@ end
170170
function __init__()
171171
global const isjulia_display = Bool[isdisplayok()]
172172
copy!(matplotlib, pyimport_conda("matplotlib", "matplotlib"))
173+
mvers = matplotlib[:__version__]
173174
global const version = try
174-
convert(VersionNumber, matplotlib[:__version__])
175+
convert(VersionNumber, mvers)
175176
catch
176-
v"0.0" # fallback
177+
parts = split(mvers,'.')
178+
try
179+
# handle mvers == aa.bb.cc.xx by dropping .xx, see #448
180+
convert(VersionNumber, join(parts[1:min(3,length(parts))], '.'))
181+
catch
182+
if !isempty(parts) && all(isdigit, parts[1])
183+
convert(VersionNumber, parts[1])
184+
else
185+
v"0.0" # fallback
186+
end
187+
end
177188
end
178189

179190
backend_gui = find_backend(matplotlib)

0 commit comments

Comments
 (0)