def onModuleEncounter(self, module_filename, module_name, module_kind): if module_name.hasNamespace("mpl_toolkits"): return True, "Needed by matplotlib" # some special handling for matplotlib: # depending on whether 'tk-inter' resp. 'qt-plugins' are enabled, # their matplotlib backends are included. if hasActivePlugin("tk-inter"): if module_name in ( "matplotlib.backends.backend_tk", "matplotlib.backends.backend_tkagg", "matplotlib.backend.tkagg", ): return True, "Needed for tkinter matplotplib backend" if getActiveQtPlugin() is not None: # Note, their code tries everything behind that name, the qt5 is # misleading therefore, PySide will work there too. if module_name in ( "matplotlib.backends.backend_qt5", "matplotlib.backends.backend_qt5.py", "matplotlib.backends.backend_qt5cairo.py", "matplotlib.backend.backend_qt5.py", ): return True, "Needed for Qt matplotplib backend" if module_name == "matplotlib.backends.backend_agg": return True, "Needed as standard matplotplib backend"
def onModuleEncounter(self, module_filename, module_name, module_kind): # pylint: disable=too-many-branches,too-many-return-statements if not self.scipy and module_name.hasOneOfNamespaces( "scipy", "sklearn", "skimage"): return False, "Omit unneeded components" if not self.matplotlib and module_name.hasOneOfNamespaces( "matplotlib", "skimage"): return False, "Omit unneeded components" if module_name == "scipy.sparse.csgraph._validation": return True, "Replicate implicit import" if self.matplotlib and module_name.hasNamespace("mpl_toolkits"): return True, "Needed by matplotlib" if module_name in ("cv2", "cv2.cv2", "cv2.data"): return True, "Needed for OpenCV" sklearn_mods = [ "sklearn.utils.sparsetools._graph_validation", "sklearn.utils.sparsetools._graph_tools", "sklearn.utils.lgamma", "sklearn.utils.weight_vector", "sklearn.utils._unittest_backport", "sklearn.externals.joblib.externals.cloudpickle.dumps", "sklearn.externals.joblib.externals.loky.backend.managers", ] if isWin32Windows(): sklearn_mods.extend([ "sklearn.externals.joblib.externals.loky.backend.synchronize", "sklearn.externals.joblib.externals.loky.backend._win_wait", "sklearn.externals.joblib.externals.loky.backend._win_reduction", "sklearn.externals.joblib.externals.loky.backend.popen_loky_win32", ]) else: sklearn_mods.extend([ "sklearn.externals.joblib.externals.loky.backend.synchronize", "sklearn.externals.joblib.externals.loky.backend.compat_posix", "sklearn.externals.joblib.externals.loky.backend._posix_reduction", "sklearn.externals.joblib.externals.loky.backend.popen_loky_posix", ]) if self.scipy and module_name in sklearn_mods: return True, "Needed by sklearn" # some special handling for matplotlib: # depending on whether 'tk-inter' resp. 'qt-plugins' are enabled, # matplotlib backends are included. if self.matplotlib: if hasActivePlugin("tk-inter"): if module_name in ( "matplotlib.backends.backend_tk", "matplotlib.backends.backend_tkagg", "matplotlib.backend.tkagg", ): return True, "Needed for tkinter matplotplib backend" if hasActivePlugin("qt-plugins"): if module_name in ( "matplotlib.backends.backend_qt5", "matplotlib.backends.backend_qt5.py", "matplotlib.backends.backend_qt5cairo.py", "matplotlib.backend.backend_qt5.py", ): return True, "Needed for Qt5 matplotplib backend" if module_name == "matplotlib.backends.backend_agg": return True, "Needed as standard matplotplib backend"