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
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ parameters:
description: Build the documentation
type: boolean
default: true
python_version:
description: The python version to build
type: string
default: "3.8"

workflows:
build-and-test:
Expand All @@ -36,8 +40,8 @@ workflows:
setup_env: << pipeline.parameters.run-tests >>
build_args: "--no-test"
build_docs: << pipeline.parameters.build_docs >>
# HACK: force netcdf4 and hdf5 version to resolve dependency issue
env_packages: dask netcdf4 scipy netcdf4=1.5.7 h5py=3.4.0 hdf5=1.12.1
python_version: << pipeline.parameters.python_version >>
env_packages: dask netcdf4 scipy
- psyplot/test-parallel:
name: test-xarray-latest
parallelism: 2
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Fixed
-----
- the update method now only takes the coordinates that are dimensions in the
dataset see `#39 <https://github.com/psyplot/psyplot/pull/39>`__
- psyplot is now compatible with matplotlib 3.5 and python 3.10

Changed
-------
Expand Down
37 changes: 26 additions & 11 deletions psyplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,39 @@ def get_versions(requirements=True, key=None):
}
}
"""
from pkg_resources import iter_entry_points
from importlib.metadata import entry_points
ret = {'psyplot': _get_versions(requirements)}
for ep in iter_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().get('psyplot', [])
if ep.name == 'plugin']
for ep in eps:
if str(ep) in rcParams._plugins:
logger.debug('Loading entrypoint %s', ep)
if key is not None and not key(ep.module_name):

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:
mod = ep.load()
except (ImportError, ModuleNotFoundError) as e:
logger.debug("Could not import %s" % ep, exc_info=True)
logger.warning("Could not import %s" % ep)
try:
ret[str(ep.module_name)] = mod.get_versions(requirements)
except AttributeError:
ret[str(ep.module_name)] = {
'version': getattr(mod, 'plugin_version',
getattr(mod, '__version__', ''))}
logger.debug("Could not import %s" % (ep, ), exc_info=True)
logger.warning("Could not import %s" % (ep, ), exc_info=True)
else:
try:
ret[str(ep.module)] = mod.get_versions(requirements)
except AttributeError:
ret[str(ep.module)] = {
'version': getattr(
mod, 'plugin_version',
getattr(mod, '__version__', ''))
}
if key is None:
try:
import psyplot_gui
Expand Down
2 changes: 1 addition & 1 deletion psyplot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def main(args=None):
The parser that has been used from the command line"""
try:
from psyplot_gui import get_parser as _get_parser
except ImportError:
except (ImportError, ModuleNotFoundError) as e:
logger.debug('Failed to import gui', exc_info=True)
parser = get_parser(create=False)
parser.update_arg('output', required=True)
Expand Down
29 changes: 20 additions & 9 deletions psyplot/config/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,16 +755,22 @@ def _load_plugin_entrypoints(self):

Yields
------
pkg_resources.EntryPoint
importlib.metadata.EntryPoint
The entry point for the psyplot plugin module"""
from pkg_resources import iter_entry_points
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_name in exclude_plugins:
elif ep.module in exclude_plugins:
return False
elif include_plugins and ep.module_name not in include_plugins:
elif include_plugins and ep.module not in include_plugins:
return False
return True

Expand All @@ -776,7 +782,12 @@ def load_plugin(ep):

logger = logging.getLogger(__name__)

for ep in iter_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().get('psyplot', [])
if ep.name == 'plugin']
for ep in eps:
if not load_plugin(ep):
logger.debug('Skipping entrypoint %s', ep)
continue
Expand Down Expand Up @@ -811,7 +822,7 @@ def load_plugins(self, raise_error=False):
def_keys = {'default': defaultParams}

def register_pm(ep, name):
full_name = '%s:%s' % (ep.module_name, name)
full_name = '%s:%s' % (ep.module, name)
ret = True
if pm_env == ['no']:
ret = False
Expand All @@ -828,8 +839,8 @@ def register_pm(ep, name):
try:
plugin_mod = ep.load()
except (ModuleNotFoundError, ImportError):
logger.debug("Failed to import %s!" % ep, exc_info=True)
logger.warning("Failed to import %s!" % ep)
logger.debug("Failed to import %s!" % (ep, ), exc_info=True)
logger.warning("Failed to import %s!" % (ep, ))
continue
rc = plugin_mod.rcParams

Expand All @@ -852,7 +863,7 @@ def register_pm(ep, name):
else:
warn(msg)
for d in plugin_plotters.values():
d['plugin'] = ep.module_name
d['plugin'] = ep.module
plotters.update(plugin_plotters)
def_plots[ep] = list(plugin_plotters)

Expand Down
1 change: 1 addition & 0 deletions psyplot/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,7 @@ def load_figure(d, new_fig=True):
subplotpars = d.pop('subplotpars', None)
if subplotpars is not None:
subplotpars.pop('validate', None)
subplotpars.pop('_validate', None)
subplotpars = mfig.SubplotParams(**subplotpars)
if new_fig:
nums = plt.get_fignums()
Expand Down