@everywhere and PackageCompiler build_executable()

I am trying to build an executable using a package I created. The code makes use of pmap to run on multiple workers.

I created a new module with the function name as per PackageCompiler recommendations and compiled with build_executable(). This all worked fine, created an .exe that does what it is expected.

However, I need to run my code in parallel. When i use the package normally I would type: @everywhere using PkgX when loading the package and use pmap to execute the function contained in PkgX. This works well when using the package within Julia code.

If I add the line @everywhere using PkgX within the function (julia_main) I get a build error. Without it, the functions of interest are not distributed to the workers and therefore as soon as I addprocs(x) the executable no longer works (the same code works on a single worker).

Any ideas? Thanks!

2 Likes

This is several years late but in case useful to others, I’ve into the same/similar issue and resolved with:

@eval @everywhere begin
    using Statistics
end

This is for create_app(), which I assume has replaced build_executable() in the past 4 years or so.