I have a feeling I’m going about his the wrong way, so I’m happy to be told how to do it properly.
I have package MajoranaReps wants to load MathLink if it is installed. However, since MathLink uses proprietary software (Mathematica) i cannot rely/nor force everyone to install it.
Also MajoranaReps works fine even without MathLink, it just loses some functionality.
To solve its i added a check when the package loads to check if MathLink is installed
isinstalled(pkg::String) = any(x -> x.name == pkg && x.is_direct_dep, values(Pkg.dependencies()))
HasMathLink=isinstalled("MathLink")
if HasMathLink
using MathLink ###if Mathlink is present also load it...
end
This solution passes the JuliRegistrator auto-merge checks so i was happy.
However when trying to load the package with using MajoranaReps I get the error
ERROR: LoadError: ArgumentError: Package MajoranaReps does not have MathLink in its dependencies:
To summarize: I do not want to add MathLink as a dependency in the .toml file (since uses would need to install mathematica), but I still want to be able to load MathLink if is exists.
I am not 100% sure I understand your use case: You are developing MajoranaReps.jl?
Then you could do something with requires.jl like we did here
This does the following: If you either have loaded Plots (that is using Plots) _before_ or _after_ using Manifolds, the part of recipes.jl (that is plotting stuff we define) is loaded.
For that to work add MathLink to the extras, see
edit: note that the usings we have in the first code snippet just load those packages within our package, if you want to bring more stuff to the users namespace you will have to add exports in that part as well.