Exclude packages from PackageCompiler create_app precompilation

Is there a way to avoid PackageCompiler.jl’s create_app compiling specific packages within a Project.toml?

I have a package I’m working on that includes Plots in the Project.toml for debugging and testing. Any calls to Plots (except the initial import Plots) is contained within if statements not executed by default. I’m using PackageCompiler.jl’s create_app to make an executable version of this package, but do not want the plotting functionality accessible through the executable. When I try to do this, create_app spends a large amount of time compiling the Plots package. How can I prevent this without removing Plots from the Project.toml? It looks like there’s a way to do this in create_sysimage but I don’t see the equivalent for an app.

include_transitive_dependencies=false might be what you’re needing there, if I’m understanding your requirement right. It should work for create_app as well as create_sysimage.

https://github.com/JuliaLang/PackageCompiler.jl/blob/94fdba2b99b7f0d3be9906de831c1ca6a0091488/src/PackageCompiler.jl#L665-L667

I don’t think that’s quite what I’m looking for. I tried using include_transitive_dependencies=false and removed all references to Plots in the package itself, except for the the .toml files. create_app still tries to put the Plots package and all the packages that it depends on into the sysimage.

I have a fairly similar situation where I have several packages that I only uses for testing.

The solution that I found to work the best is to have a separate project for testing that has the package as a dependency as well as all the other testing packages like plot. And when I build the app I use the package project. Of course for this to work you need to remove all mentions of Plots inside your package and only mention it in the test scripts.

Yes, I wound up doing something similar as a workaround, but definitely not ideal.