Skip to content

Conditional module availability based on available dependencies #18

@achilleas-k

Description

@achilleas-k

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions