-
Notifications
You must be signed in to change notification settings - Fork 28
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
Warning when conditionally loading "glue" module #65
Comments
This might be best asked on Pkg.jl or similar. I'm not sure but you might be able to give |
Cross posted to JuliaLang/Pkg.jl#1238 |
I tried that, but unfortunately I still get the same warning. |
Also cross posted to JuliaLang/julia#32413 |
Hi, I just came across this in Julia's issue tracker. I think I found a very evil solution to this: module MyPlayground
using Pkg
using Requires
const gluepkg = Base.PkgId(Base.UUID("197e495a-9878-11e9-311c-51fb68a00c9c"),
"GlueModule")
function __init__()
@require JSON="682c06a0-de6a-54ab-a142-c8b1cf79cde6" begin
if Base.locate_package(gluepkg) === nothing
Pkg.develop(PackageSpec(
path=joinpath(@__DIR__, "..", "GlueModule")
))
end
const GlueModule = Base.require(gluepkg)
end
end
end # module See the full code here: tkf/MyPlayground.jl@5343249 |
Hmmm, the problem with calling |
Maybe using |
It looks like the signature of |
What I had in mind was something like this but it didn't work (same warning message as yours). Looking at If you are interested in precompiling conditional dependency support, see this hack by Roger-luo or an alternative idea I posted. |
Yeah it seems like tricking Julia and Pkg is a bad idea. I think ultimately we need first-class support for this in the Julia language and/or Pkg. |
OK I think I figured it out. As usual in programming, one more indirection helps. This seems to work: using Requires
const gluepkg = Base.PkgId(Base.UUID("197e495a-9878-11e9-311c-51fb68a00c9c"),
"GlueModule")
function __init__()
@require JSON="682c06a0-de6a-54ab-a142-c8b1cf79cde6" begin
const GlueModule = let
glueloader = joinpath(dirname(@__DIR__), "GlueModule", "loader", "Project.toml")
origpath = copy(Base.LOAD_PATH)
pushfirst!(Base.LOAD_PATH, glueloader)
try
Base.require(gluepkg)
finally
append!(empty!(Base.LOAD_PATH), origpath)
end
end
end
end The idea is to have a "loader" environment |
I'm facing a similar issue and haven't found a conclusion in this thread. After issuing e.g.: @require Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" begin
@eval using Makie
include("./my-extra-plots.jl")
export my_extra_plot
end I get the same Warning/Error as the original poster. |
I can conditionally load code like this:
ExampleOne.jl
:But code loaded like this is not precompiled.
If I want to be able to precompile my conditionally loaded code, I can do so like this:
ExampleTwo.jl
:Where the contents of
GlueModule.jl
are:With this approach,
GlueModule
is precompiled. Unfortunately, I get this warning:I understand the purpose of the "Warning: Package
Foo
does not haveBar
in its dependencies" warning whenBar
is a real package with a UUID that is in the Julia General registry and can be added to aProject.toml
file. But in this case,GlueModule
isn't a real package - it's a glue module that is located in the same package repository asExampleTwo
.GlueModule
doesn't have its own GitHub repository, doesn't have its own UUID, is not separately registered in the Julia General registry, and cannot be added to aProject.toml
file.So is there a way to suppress the "Warning: Package
ExampleTwo
does not haveGlueModule
in its dependencies" warning for glue modules that are conditionally loaded by Requires.jl?The text was updated successfully, but these errors were encountered: