Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
psyplot: psyplot/psyplot-ci-orb@1.5.29
psyplot: psyplot/psyplot-ci-orb@1.5.31
mattermost-plugin-notify: nathanaelhoun/mattermost-plugin-notify@1.2.0

executors:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.4.2
======
Fix for compatibility with python 3.7

v1.4.1
======
Compatibility fixes and minor improvements
Expand Down
10 changes: 3 additions & 7 deletions psyplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,10 @@ def get_versions(requirements=True, key=None):
}
}
"""
from importlib.metadata import entry_points
ret = {'psyplot': _get_versions(requirements)}
from psyplot.utils import plugin_entrypoints
eps = plugin_entrypoints("psyplot", "plugin")

try:
eps = entry_points(group='psyplot', name='plugin')
except TypeError: # python<3.10
eps = [ep for ep in entry_points().get('psyplot', [])
if ep.name == 'plugin']
ret = {'psyplot': _get_versions(requirements)}
for ep in eps:
if str(ep) in rcParams._plugins:
logger.debug('Loading entrypoint %s', ep)
Expand Down
13 changes: 6 additions & 7 deletions psyplot/config/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,17 @@ def _load_plugin_entrypoints(self):
------
importlib.metadata.EntryPoint
The entry point for the psyplot plugin module"""
from importlib.metadata import entry_points
from psyplot.utils import plugin_entrypoints

def load_plugin(ep):

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

if plugins_env == ['no']:
return False
Expand All @@ -782,11 +785,7 @@ def load_plugin(ep):

logger = logging.getLogger(__name__)

try:
eps = entry_points(group='psyplot', name='plugin')
except TypeError: # python<3.10
eps = [ep for ep in entry_points().get('psyplot', [])
if ep.name == 'plugin']
eps = plugin_entrypoints("psyplot", "plugin")
for ep in eps:
if not load_plugin(ep):
logger.debug('Skipping entrypoint %s', ep)
Expand Down
16 changes: 16 additions & 0 deletions psyplot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# You should have received a copy of the GNU LGPL-3.0 license
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import sys
import re
import six
from difflib import get_close_matches
Expand All @@ -31,6 +32,21 @@
from psyplot.docstring import dedent, docstrings


def plugin_entrypoints(group="psyplot", name="name"):
"""This utility function gets the entry points of the psyplot plugins"""
if sys.version_info[:2] > (3, 7):
from importlib.metadata import entry_points
try:
eps = entry_points(group=group, name=name)
except TypeError: # python<3.10
eps = [ep for ep in entry_points().get(group, [])
if ep.name == name]
else:
from pkg_resources import iter_entry_points
eps = iter_entry_points(group=group, name=name)
return eps


class DefaultOrderedDict(OrderedDict):
"""An ordered :class:`collections.defaultdict`

Expand Down