networkx / networkx-metis

NetworkX Addon to allow graph partitioning with METIS
Other
79 stars 21 forks source link

Make nxmetis importable even if nxmetis._metis is not built #52

Closed ysitu closed 9 years ago

ysitu commented 9 years ago

When building documentation, autodoc attempts to import nxmetis. If nxmetis._metis is not built, import will fail and cause errors. One solution is to modify imports of _metis in __init__.py and types.py to read

try:
    from nxmetis import _metis
except ImportError:
    pass

But I think that it is probably better to create a metis.py that imports stuff from _metis

try:
    from nxmetis._metis import node_nd, ...
except ImportError:
    def node_nd(*args, **kargs):
        raise ...
    ...

and import metis instead of _metis in __init__.py and types.py.

OrkoHunter commented 9 years ago

Having a metis.py was better already because it also keeps us away from the possibly of a circular import since things inside __init__.py always gets imported whenever a nxmetis.xyz is imported.

ysitu commented 9 years ago

Let's not go that far for this particular issue. Wrapping _metis alone suffices.