Skip to content

Commit

Permalink
MAINT: Less noisy output with missing env plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Jan 19, 2025
1 parent 9cfd6cf commit 19593f2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions asv/plugin_manager.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

import sys
import re
import pkgutil
import importlib

from . import commands, plugins
from .console import log

ENV_PLUGINS = [".mamba", "._mamba_helpers", ".virtualenv", ".conda", ".rattler"]
ENV_PLUGIN_REGEXES = [
r"\.mamba$",
r"\._mamba_helpers$",
r"\.virtualenv$",
r"\.conda$",
r"\.rattler$",
]


class PluginManager:
"""
Expand All @@ -25,20 +33,24 @@ def __init__(self):

def load_plugins(self, package):
prefix = package.__name__ + "."
for module_finder, name, ispkg in pkgutil.iter_modules(package.__path__, prefix):
for module_finder, name, ispkg in pkgutil.iter_modules(
package.__path__, prefix
):
try:
mod = importlib.import_module(name)
self.init_plugin(mod)
self._plugins.append(mod)
except ModuleNotFoundError as err:
if any(keyword in name for keyword in ENV_PLUGINS):
if any(re.search(regex, name) for regex in ENV_PLUGIN_REGEXES):
continue # Fine to not have these
else:
log.error(f"Couldn't load {name} because\n{err}")

def _load_plugin_by_name(self, name):
prefix = plugins.__name__ + "."
for module_finder, module_name, ispkg in pkgutil.iter_modules(plugins.__path__, prefix):
for module_finder, module_name, ispkg in pkgutil.iter_modules(
plugins.__path__, prefix
):
if name in module_name:
mod = importlib.import_module(module_name)
return mod
Expand Down

0 comments on commit 19593f2

Please sign in to comment.