def has_binding_new(api):
 module_name = api_to_module[api]
 from importlib.util import find_spec
 required = ['QtCore', 'QtGui', 'QtSvg']
 if (api in (QT_API_PYQT5, QT_API_PYSIDE2)):
  required.append('QtWidgets')
 for submod in required:
  try:
   spec = find_spec(('%s.%s' % (module_name, submod)))
  except ImportError:
   return False
  else:
   if (spec is None):
    return False
 if (api == QT_API_PYSIDE):
  import PySide
  return check_version(PySide.__version__, '1.0.3')
 return True

def has_binding_new ( api ) : module_name = api_to_module [ api ] from importlib . util import find_spec required = [ 'QtCore' , 'QtGui' , 'QtSvg' ] if ( api in ( QT_API_PYQT5 , QT_API_PYSIDE2 ) ) : required . append ( 'QtWidgets' ) for submod in required : try : spec = find_spec ( ( '%s.%s' % ( module_name , submod ) ) ) except ImportError : return False else : if ( spec is None ) : return False if ( api == QT_API_PYSIDE ) : import PySide return check_version ( PySide . __version__ , '1.0.3' ) return True
safely check for pyqt4/5 .