Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional module availability based on available dependencies #18

Open
achilleas-k opened this issue Sep 26, 2019 · 0 comments
Open

Comments

@achilleas-k
Copy link
Member

One of the initial ideas we discussed for this package was that each submodule would have a different set of dependencies and they would all be "optional dependencies". For instance, the nixworks.table module shouldn't be available if Pandas isn't installed and the nixworks.plotter shouldn't be available without Matplotlib. The general idea is that users shouldn't need to install Pandas if they only want the plotting and vice versa. This will be more important as more modules get added.

We should figure out a nice way to conditionally enable submodules based on available dependencies. This could be a simple try catch in the module's files (e.g., in nixworks/table/table.py):

try:
    import pandas
except ImportError:
   raise ImportError("Module 'table' requires Pandas")

but perhaps it would be nicer if the top-level __init__.py did all the import checking and marked modules available or not with appropriate error messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant