Skip to content
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

using PyPlot crashes package precompilation on Julia v1.10.0-beta1 #572

Closed
pszufe opened this issue Jul 29, 2023 · 4 comments
Closed

using PyPlot crashes package precompilation on Julia v1.10.0-beta1 #572

pszufe opened this issue Jul 29, 2023 · 4 comments

Comments

@pszufe
Copy link

pszufe commented Jul 29, 2023

[this is also cross-post on PyCall https://github.com/JuliaPy/PyCall.jl/issues/1047]

Consider the following package:

(@v1.10) pkg> generate Test1
  Generating  project Test1:
    Test1\Project.toml
    Test1\src\Test1.jl

Where PyPlot has been added via Pkg.add to dependencies and Test1.jl contains

module Test1
using PyPlot
end 

In that case using Test1 (after Pkg.activate) goes into an endless loop (I pressed Ctrl+C at some point):

julia> using Test1
Precompiling Test1
  Progress [>                                        ]  0/1
  ◑ Test1 Waiting for background task / IO / timer. Interrupt to inspect
 Interrupted: Exiting precompilation...

  1 dependency had warnings during precompilation:
┌ Test1 [ddca8587-cad1-46e2-86b4-b726afea1d60]
│  [pid 7156] waiting for IO to finish:
│   TYPE[FD/PID]       @UV_HANDLE_T->DATA
│   timer              @00000228c312eca0->00000228bf815db0
└

When this is run on a fresh Julia installation it seemed that it additionally tries to install matplotlib via Conda (regardless of the fact that it is already present due to PyPlot being built earlier).

Tested on Julia 1.10 beta1, Windows11 as well Linux by myself and @giordano

@MilesCranmer
Copy link

Probably the same as discussed on this issue: comonicon/Comonicon.jl#249

i.e., this block:

PyPlot.jl/src/init.jl

Lines 171 to 209 in 343430a

function __init__()
ccall(:jl_generating_output, Cint, ()) == 1 && return nothing
isjulia_display[] = isdisplayok()
copy!(matplotlib, pyimport_conda("matplotlib", "matplotlib"))
mvers = matplotlib.__version__
global version = try
vparse(mvers)
catch
v"0.0.0" # fallback
end
backend_gui = find_backend(matplotlib)
# workaround JuliaLang/julia#8925
global backend = backend_gui[1]
global gui = backend_gui[2]
copy!(plt, pyimport("matplotlib.pyplot")) # raw Python module
pytype_mapping(plt."Figure", Figure)
copy!(Gcf, pyimport("matplotlib._pylab_helpers")."Gcf")
copy!(orig_gcf, plt."gcf")
copy!(orig_figure, plt."figure")
plt."gcf" = gcf
plt."figure" = figure
if isdefined(Main, :IJulia) && Main.IJulia.inited
Main.IJulia.push_preexecute_hook(force_new_fig)
Main.IJulia.push_postexecute_hook(display_figs)
Main.IJulia.push_posterror_hook(close_figs)
end
if isjulia_display[] && gui != :gr && backend != "Agg"
plt."switch_backend"("Agg")
plt."ioff"()
end
init_colormaps()
end
is opening I/O resources and not closing them, which is not allowed on 1.10

See JuliaPlots/PlotlyKaleido.jl#6 for an example of a fix. I guess PyPlot.jl will have to do something similar

@timholy
Copy link
Contributor

timholy commented Aug 14, 2023

This was already fixed in #565, we just need a new release. (Last release was in March, before that PR was merged.)

@MilesCranmer
Copy link

Ah, that explains it :)

@stevengj
Copy link
Member

Closed by JuliaRegistries/General#89626

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

No branches or pull requests

4 participants