Conditional package dependency to avoid build errors

Usually you put the special feature that depends on Gurobi in some file filerequiringgurobi.l in anyMod.jl and load this using Requires.jl as follows:

function __init__()
    @require Gurobi="uuid of Gurobi" include("filerequiringgurobi.jl")
end

Then once one does using Gurobi (which implies hopefully a proper installation of Gurobi and the additional software), then the additional feature is loaded.

Probably I misunderstood the question, but isn’t this what you want?

1 Like