Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
compatibility fixes for python<3.10
  • Loading branch information
Chilipp committed Nov 21, 2021
commit d1373c11c9ab9e0583eb454bc274c0d25c1107b5
14 changes: 13 additions & 1 deletion psyplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,21 @@ def get_versions(requirements=True, key=None):
"""
from importlib.metadata import entry_points
ret = {'psyplot': _get_versions(requirements)}
for ep in entry_points(group='psyplot', name='plugin'):

try:
eps = entry_points(group='psyplot', name='plugin')
except TypeError: # python<3.10
eps = [ep for ep in entry_points()['psyplot']
if ep.name == 'plugin']
for ep in eps:
if str(ep) in rcParams._plugins:
logger.debug('Loading entrypoint %s', ep)

try:
ep.module
except AttributeError: # python<3.10
ep.module = ep.pattern.match(ep.value).group("module")

if key is not None and not key(ep.module):
continue
try:
Expand Down
13 changes: 12 additions & 1 deletion psyplot/config/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,12 @@ def _load_plugin_entrypoints(self):
from importlib.metadata import entry_points

def load_plugin(ep):

try:
ep.module
except AttributeError: # python<3.10
ep.module = ep.pattern.match(ep.value).group("module")

if plugins_env == ['no']:
return False
elif ep.module in exclude_plugins:
Expand All @@ -776,7 +782,12 @@ def load_plugin(ep):

logger = logging.getLogger(__name__)

for ep in entry_points(group='psyplot', name='plugin'):
try:
eps = entry_points(group='psyplot', name='plugin')
except TypeError: # python<3.10
eps = [ep for ep in entry_points()['psyplot']
if ep.name == 'plugin']
for ep in eps:
if not load_plugin(ep):
logger.debug('Skipping entrypoint %s', ep)
continue
Expand Down