Description
Currently, compile_incremental(:PyCall)
generates incremental_precompile.jl
containing something like
using Pkg, Statistics, Test, Libdl, Conda, Serialization, LinearAlgebra,
PyCall, VersionParsing, MacroTools, Dates, PackageCompiler
for Mod in [Pkg, Statistics, Test, Libdl, Conda, Serialization, LinearAlgebra,
PyCall, VersionParsing, MacroTools, Dates, PackageCompiler]
isdefined(Mod, :__init__) && Mod.__init__()
end
PyCall
depends on MacroTools
(Conda
, and VersionParsing
). Furthermore, in principle, PyCall
's top-level code and macros can depend on the global state configured in MacroTools.__init__
(PyCall
does not depend on it ATM. However, you can check it by adding, e.g., println(MacroTools.@expand @time foo())
in PyCall.__init__
). So, shouldn't using MacroTools
and MacroTools.__init__()
come before using PyCall
? That is to say, I think incremental_precompile.jl
needs to contain something like
for name in [...,
:MacroTools,
:VersionParsing,
:Conda,
:PyCall,
...]
Core.eval(@__MODULE__, :(using $name))
Mod = Core.eval(@__MODULE__, name)
isdefined(Mod, :__init__) && Mod.__init__()
end
In general, I think the packages have to be imported and __init__
'ed in the topologically sorted order. Or maybe it is better be fixed in Julia side? JuliaLang/julia#22910