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

Does not work on Julia 0.7 #45

Closed
Datseris opened this issue Jun 16, 2018 · 17 comments
Closed

Does not work on Julia 0.7 #45

Datseris opened this issue Jun 16, 2018 · 17 comments

Comments

@Datseris
Copy link

@tpapp already mentioned it in #44 , but a dedicated issue may be better.

This currently does not work on 0.7:

using Requires
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" begin
    dir = joinpath(@__DIR__, "plotting")
    for f in readdir(dir)
        include(joinpath(dir, f))
    end
end

does not actually load the code when using PyPlot.

(I am not on any master branch, just the default version I got from pkg add Requires)

@MikeInnes
Copy link
Collaborator

Is it actually specific to begin blocks? To answer @tpapp's question, you can look at where the listener is registered here, and when a package is actually loaded this should get called. If you @show the inputs here you should be able to narrow down what's not running here.

@Datseris
Copy link
Author

Hi @MikeInnes , this is not fixed yet but I also can't follow what you posted. It is totally cryptic for me, since I don't really know how the source works.

@Datseris
Copy link
Author

I can confirm that this is not related to begin.

i changed my code to:

using Requires
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" include("plotting/obstacles.jl")
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" include("plotting/particles.jl")
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" include("plotting/billiards.jl")
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" include("plotting/animations.jl")
@require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" include("plotting/psos.jl")

and still doesn't work. Could it be an issue with the UUID I am using?

@tpapp
Copy link

tpapp commented Jun 21, 2018

I could not figure it out either.

@tpapp
Copy link

tpapp commented Jun 25, 2018

Update: apparently listenpkg does not get called. The expression for @require is expanded, but ends up in the isprecompiling() == true branch, and that is somehow never called.

This is on v"0.7.0-beta.7", and master for this package.

@Datseris Datseris changed the title Does not work with begin blocks on Julia 0.7 Does not work on Julia 0.7 Jul 3, 2018
@Datseris
Copy link
Author

Datseris commented Jul 3, 2018

Changed the title to reflect what is actually happening

@tpapp
Copy link

tpapp commented Jul 3, 2018

I tried this at the time of opening #44, so it may not be correct anymore, but when I did an MWE with @require, that worked. I will try the MWE again, and if that works, maybe I can pare down PGFPlotsX to the point this just stops working — I guess na MWE would help.

@tpapp
Copy link

tpapp commented Jul 8, 2018

MWE here.

@Datseris
Copy link
Author

After updating to 0.5.1 (after Merging Tim Holy's PR) I tried again, using the new syntax.

It does not work, because it cannot find the modules PyPlot (my requested module) is depending on:

# the following happens whether I first do using PyPlot and then DynamicalBilliards
# or vice versa

ERROR: LoadError: LoadError: ArgumentError: Package Colors not found in current path:
 - Run `Pkg.add("Colors")` to install the Colors package.

Stacktrace:
 [1] require(::Module, ::Symbol) at .\loading.jl:816
 [2] include at .\boot.jl:317 [inlined]
 [3] include_relative(::Module, ::String) at .\loading.jl:1034
 [4] include at .\sysimg.jl:29 [inlined]
 [5] include(::String) at C:\Users\datseris\.julia\packages\PyPlot\16Fy\src\PyPlot.jl:3
 [6] top-level scope at none:0
 [7] include at .\boot.jl:317 [inlined]
 [8] include_relative(::Module, ::String) at .\loading.jl:1034
 [9] include(::Module, ::String) at .\sysimg.jl:29
 [10] top-level scope at none:0
 [11] eval at .\boot.jl:319 [inlined]
 [12] eval(::Expr) at .\client.jl:394
 [13] top-level scope at .\none:3 [inlined]
 [14] top-level scope at .\<missing>:0
in expression starting at C:\Users\datseris\.julia\packages\PyPlot\16Fy\src\colormaps.jl:4
in expression starting at C:\Users\datseris\.julia\packages\PyPlot\16Fy\src\PyPlot.jl:198
┌ Warning: Error requiring PyPlot from DynamicalBilliards:
│ Failed to precompile PyPlot to C:\Users\datseris\.julia\compiled\v0.7\PyPlot.ji.
│ Stacktrace:
│  [1] error(::String) at .\error.jl:33
│  [2] macro expansion at .\logging.jl:298 [inlined]
│  [3] compilecache(::Base.PkgId) at .\loading.jl:1173
│  [4] _require(::Base.PkgId) at .\loading.jl:942
│  [5] require(::Base.PkgId) at .\loading.jl:838
│  [6] top-level scope at none:0
│  [7] eval at .\boot.jl:319 [inlined]
│  [8] eval at C:\Users\datseris\.julia\dev\DynamicalBilliards\src\DynamicalBilliards.jl:10 [inlined]
│  [9] (::getfield(DynamicalBilliards, Symbol("##52#55")))() at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:67
│  [10] err(::getfield(DynamicalBilliards, Symbol("##52#55")), ::Module, ::String) at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:38
│  [11] #51 at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:66 [inlined]
│  [12] withpath(::getfield(DynamicalBilliards, Symbol("##51#54")), ::String) at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:28
│  [13] #50 at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:65 [inlined]
│  [14] listenpkg(::getfield(DynamicalBilliards, Symbol("##50#53")), ::Base.PkgId) at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:13
│  [15] macro expansion at C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:64 [inlined]
│  [16] __init__() at C:\Users\datseris\.julia\dev\DynamicalBilliards\src\DynamicalBilliards.jl:70
│  [17] _include_from_serialized(::String, ::Array{Any,1}) at .\loading.jl:600
│  [18] _require_from_serialized(::String) at .\loading.jl:662
│  [19] macro expansion at .\logging.jl:299 [inlined]
│  [20] _require(::Base.PkgId) at .\loading.jl:929
│  [21] require(::Base.PkgId) at .\loading.jl:838
│  [22] require(::Module, ::Symbol) at .\loading.jl:833
│  [23] eval(::Module, ::Any) at .\boot.jl:319
│  [24] eval_user_input(::Any, ::REPL.REPLBackend) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:85
│  [25] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:116 [inlined]
│  [26] (::getfield(REPL, Symbol("##28#29")){REPL.REPLBackend})() at .\task.jl:257
└ @ Requires C:\Users\datseris\.julia\packages\Requires\uXN8\src\require.jl:40

Notice that using PyPlot works fine.

The way I do it in my package is:

using Requires
function __init__()
    @require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" begin
        using PyPlot
        dir = joinpath(@__DIR__, "plotting")
        for f in readdir(dir)
            include(joinpath(dir, f))
        end
    end
end

@timholy you may be interested as well.

@Datseris
Copy link
Author

An extra error is the very fact that it tries to precompile PyPlot. It is already pre-compiled so this is probably a bug:


julia> using PyPlot

julia> using DynamicalBilliards

[ Info: Precompiling module PyPlot

ERROR: LoadError: LoadError: ArgumentError: Package Colors not found in current path:
 - Run `Pkg.add("Colors")` to install the Colors package.

@timholy
Copy link
Member

timholy commented Jul 11, 2018

See #48 (comment)

@Datseris
Copy link
Author

Update, after version 0.5.2. It still doesn't seem to behave as intended:

┌ Warning: Error requiring PyPlot from DynamicalBilliards:
│ LoadError: ArgumentError: Package DynamicalBilliards does not have PyPlot in its dependencies:
│  - If you have DynamicalBilliards checked out for development and have
│    added PyPlot as a dependency but haven't updated your primary
│    environment's manifest file, try `Pkg.resolve()`.
│  - Otherwise you may need to report an issue with DynamicalBilliards.
│
│ Stacktrace:
│  [1] require(::Module, ::Symbol) at .\loading.jl:821
│  [2] include at .\boot.jl:317 [inlined]
│  [3] include_relative(::Module, ::String) at .\loading.jl:1034
│  [4] include at .\sysimg.jl:29 [inlined]
│  [5] include(::String) at C:\Users\datseris\.julia\dev\DynamicalBilliards\src\DynamicalBilliards.jl:10
│  [6] top-level scope at C:\Users\datseris\.julia\dev\DynamicalBilliards\src\DynamicalBilliards.jl:65
│  [7] eval at .\boot.jl:319 [inlined]
│  [8] eval at C:\Users\datseris\.julia\dev\DynamicalBilliards\src\DynamicalBilliards.jl:10 [inlined]
│  [9] (::getfield(DynamicalBilliards, Symbol("##52#55")))() at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:67
│  [10] err(::getfield(DynamicalBilliards, Symbol("##52#55")), ::Module, ::String) at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:38
│  [11] #51 at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:66 [inlined]
│  [12] withpath(::getfield(DynamicalBilliards, Symbol("##51#54")), ::String) at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:28
│  [13] (::getfield(DynamicalBilliards, Symbol("##50#53")))() at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:65
│  [14] #invokelatest#1 at .\essentials.jl:660 [inlined]
│  [15] invokelatest at .\essentials.jl:659 [inlined]
│  [16] #3 at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:19 [inlined]
│  [17] iterate at .\generator.jl:47 [inlined]
│  [18] _collect(::Array{Function,1}, ::Base.Generator{Array{Function,1},getfield(Requires, Symbol("##3#4"))}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at .\array.jl:607
│  [19] map at .\array.jl:536 [inlined]
│  [20] loadpkg(::Base.PkgId) at C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:19
│  [21] #invokelatest#1 at .\essentials.jl:660 [inlined]
│  [22] invokelatest at .\essentials.jl:659 [inlined]
│  [23] require(::Base.PkgId) at .\loading.jl:841
│  [24] require(::Module, ::Symbol) at .\loading.jl:833
│  [25] eval(::Module, ::Any) at .\boot.jl:319
│  [26] eval_user_input(::Any, ::REPL.REPLBackend) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:85
│  [27] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:116 [inlined]
│  [28] (::getfield(REPL, Symbol("##28#29")){REPL.REPLBackend})() at .\task.jl:257
│ in expression starting at C:\Users\datseris\.julia\dev\DynamicalBilliards\src\plotting\animations.jl:1
└ @ Requires C:\Users\datseris\.julia\packages\Requires\9Jse\src\require.jl:40

julia>

@Datseris
Copy link
Author

Datseris commented Jul 13, 2018

I get identical error even if I put PyPlot in my Project.toml ...

This is what I have at the end of the DynamicalBilliards.jl file:

using Requires
function __init__()
    @require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" begin
        dir = joinpath(@__DIR__, "plotting")
        for f in readdir(dir)
            include(joinpath(dir, f))
        end
    end
end


end # module

@davidanthoff
Copy link
Contributor

Also doesn't work here on my end. In IterableTables.jl I have:

__precompile__()
module IterableTables

using Requires

function __init__()
    @require DataFrames="a93c6f00-e57d-5684-b7b6-d8193f3e46c0" include("integrations/dataframes.jl") 
end

end # module

And then in integrations/dataframes.jl:

import DataFrames

And then I get this:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-beta.279 (2018-07-12 15:33 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit b0f531e5f0* (1 day old master)
|__/                   |  x86_64-w64-mingw32

julia> using IterableTables

julia> using DataFrames
┌ Warning: Error requiring DataFrames from IterableTables:
│ LoadError: ArgumentError: Package IterableTables does not have DataFrames in its dependencies:
│  - If you have IterableTables checked out for development and have
│    added DataFrames as a dependency but haven't updated your primary
│    environment's manifest file, try `Pkg.resolve()`.
│  - Otherwise you may need to report an issue with IterableTables.
│
│ Stacktrace:
│  [1] require(::Module, ::Symbol) at .\loading.jl:821
│  [2] include at .\boot.jl:317 [inlined]
│  [3] include_relative(::Module, ::String) at .\loading.jl:1034
│  [4] include at .\sysimg.jl:29 [inlined]
│  [5] include(::String) at C:\Users\david\.julia\dev\IterableTables\src\IterableTables.jl:2
│  [6] top-level scope at none:0
│  [7] eval at .\boot.jl:319 [inlined]
│  [8] eval at C:\Users\david\.julia\dev\IterableTables\src\IterableTables.jl:2 [inlined]
│  [9] (::getfield(IterableTables, Symbol("##3#6")))() at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:67
│  [10] err(::getfield(IterableTables, Symbol("##3#6")), ::Module, ::String) at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:38
│  [11] #2 at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:66 [inlined]
│  [12] withpath(::getfield(IterableTables, Symbol("##2#5")), ::String) at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:28
│  [13] (::getfield(IterableTables, Symbol("##1#4")))() at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:65
│  [14] #invokelatest#1 at .\essentials.jl:660 [inlined]
│  [15] invokelatest at .\essentials.jl:659 [inlined]
│  [16] #3 at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:19 [inlined]
│  [17] iterate at .\generator.jl:47 [inlined]
│  [18] _collect(::Array{Function,1}, ::Base.Generator{Array{Function,1},getfield(Requires, Symbol("##3#4"))}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at .\array.jl:607
│  [19] map at .\array.jl:536 [inlined]
│  [20] loadpkg(::Base.PkgId) at C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:19
│  [21] #invokelatest#1 at .\essentials.jl:660 [inlined]
│  [22] invokelatest at .\essentials.jl:659 [inlined]
│  [23] require(::Base.PkgId) at .\loading.jl:841
│  [24] require(::Module, ::Symbol) at .\loading.jl:833
│  [25] eval(::Module, ::Any) at .\boot.jl:319
│  [26] eval_user_input(::Any, ::REPL.REPLBackend) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:85
│  [27] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:116 [inlined]
│  [28] (::getfield(REPL, Symbol("##28#29")){REPL.REPLBackend})() at .\task.jl:262
│ in expression starting at C:\Users\david\.julia\dev\IterableTables\src\integrations\dataframes.jl:1
└ @ Requires C:\Users\david\.julia\packages\Requires\9Jse\src\require.jl:40

@RalphAS
Copy link

RalphAS commented Jul 14, 2018

@davidanthoff as of the recent release 0.5.2, the @requires statement effectively arranges to import the specified module (DataFrames, say) into the caller when the outer top-level world loads DataFrames. So if you drop the import DataFrames directive from your included file and explicitly qualify all DataFrame bindings therein (or make local aliases), your code might work.

Getting the equivalent of using is somewhat harder.

cc: @MikeInnes @Datseris

Edit: to clarify, the import statement would be redundant, but it actually calls into Package-framework-dependent code that doesn't work here.

@Datseris
Copy link
Author

Hi @RalphAS , thanks for letting us know.

I confirm that what you suggested does indeed work!!!!!!!!!!!!!!

However..... for me it was really hard tedious to do it: I had to go through 5 files and put PyPlot. in like 50 commands! Also, macros did not work, for example the PyPlot functionality of having the "latex strings", eg: L"$x = \phi$, could not work.

Is it impossible to recover the old behavior, where we could just do using PyPlot ?

@RalphAS
Copy link

RalphAS commented Jul 14, 2018

Unless the Julia developers are willing to change some of the loading functions (and that seems very unwise at this point in the release cycle), ISTM that using and import can't work here. One solution would be to have macros in this package (e.g. @using) which replicate the functionality for @require'd packages.

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

6 participants