Optional dependencies?


#1

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?


#2

I believe this is the recommended solution:


#3

Great, thanks @yurivish.


#4

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