python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

Remove the HAVE_PACKAGE logic and module import of extra dependency.

Open samuelgarcia opened this issue 3 years ago • 2 comments

We have this kind of logic for many IOs

try:
    import sonpy
    HAVE_SONPY = True
except ImportError:
    HAVE_SONPY = False

class SomeClass
   def __init__(self):
        assert HAVE_SONPY, 'sonpy must be installed'

This make importing many modules for every import neo because all extra dependencies are at module level. I propose to move to "import on demand" logic with this


class SomeClass
   def __init__(self):
        import sonpy

I propose to do this (it is easy) for the next release 0.11.0

@JuliaSprenger @apdavison : are you OK with this ?

samuelgarcia avatar Aug 29 '22 13:08 samuelgarcia

Yes, for IOs I think this makes sense, since it is rare to use more than one or two IOs in a given script

apdavison avatar Aug 30 '22 12:08 apdavison

OK I start this soon.

samuelgarcia avatar Aug 30 '22 12:08 samuelgarcia