Optional dependencies?


I’d like to add a function to a library that takes a DataFrame and returns the library’s type of choice (a MetaGraph). But I’d really like to avoid making DataFrames a dependency for the library.

Is there a way to create a function that is available if the user has a given library, but which isn’t require for importing the rest of the library?


I believe this is the recommended solution:


Great, thanks @yurivish.


I don’t believe this will work properly if the required package has macros that need to be used within the base code.