Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
ImportError with custom plugin #2423
For illustration I use obspyh5 as custom plugin, but I guess it would be the same for other plugins.
Consider the following setup:
The following script is working:
The following script is not working in obspy master.
@medlin01GA Thanks for spotting this mysterious bug.
It seems calling load_entry_point on a module during import of the module itself causes this problem.
--- a/obspy/core/util/base.py +++ b/obspy/core/util/base.py @@ -29,7 +29,7 @@ import numpy as np import pkg_resources import requests from future.utils import native_str -from pkg_resources import iter_entry_points +from pkg_resources import get_entry_info, iter_entry_points from obspy.core.util.misc import to_int_or_zero, buffered_load_entry_point @@ -519,8 +519,8 @@ def make_format_plugin_table(group="waveform", method="read", numspaces=4, for name, ep in eps.items(): module_short = ":mod:`%s`" % ".".join(ep.module_name.split(".")[:3]) ep_list = [ep.dist.key, "obspy.plugin.%s.%s" % (group, name), method] - func = buffered_load_entry_point(*ep_list) - func_str = ':func:`%s`' % ".".join((ep.module_name, func.__name__)) + entry_info = str(get_entry_info(*ep_list)) + func_str = ':func:`%s`' % entry_info.split(' = ').replace(':','.') mod_list.append((name, module_short, func_str)) mod_list = sorted(mod_list)
I guess this should be OK?
Ok, I have looked over the CI runs as well as run a few tests locally and I feel ok about merging this.
However, I have uncovered one issue that is partially related. If someone tries to re-import obspy it fails because the
import importlib import obspy importlib.reload(obspy)
raises a TypeError.
I tried fixing it (just pushed here), do you mind taking a look at it. After that, it should be good to merge.
Thanks for running some tests and having a look.