Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make meshio an optional dependency #1939

Merged
merged 4 commits into from
Dec 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions pyvista/core/filters/unstructured_grid.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Filters module with a class to manage filters/algorithms for unstructured grid datasets."""
from functools import wraps

import pyvista
from pyvista import abstract_class
from pyvista.core.filters.poly_data import PolyDataFilters
from pyvista.core.filters.data_set import DataSetFilters
from pyvista.core.filters.poly_data import PolyDataFilters


@abstract_class
Expand Down
10 changes: 6 additions & 4 deletions pyvista/utilities/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,14 @@ def __init__(self, additional=None, ncol=3, text_width=80, sort=False,

"""
# Mandatory packages.
core = ['pyvista', 'vtk', 'numpy', 'imageio', 'appdirs', 'scooby',
'meshio']
core = ['pyvista', 'vtk', 'numpy', 'imageio', 'appdirs', 'scooby']

# Optional packages.
optional = ['matplotlib', 'pyvistaqt', 'PyQt5', 'IPython', 'colorcet',
'cmocean', 'ipyvtklink', 'scipy', 'itkwidgets', 'tqdm']
optional = [
'matplotlib', 'pyvistaqt', 'PyQt5', 'IPython', 'colorcet',
'cmocean', 'ipyvtklink', 'scipy', 'itkwidgets', 'tqdm',
'meshio',
]

# Information about the GPU - bare except in case there is a rendering
# bug that the user is trying to report.
Expand Down
21 changes: 18 additions & 3 deletions pyvista/utilities/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ def read(filename, attrs=None, force_ext=None, file_format=None):
* ``'.foam'``

.. note::
See https://github.com/nschloe/meshio for formats supported by ``meshio``.
See https://github.com/nschloe/meshio for formats supported by
``meshio``. Be sure to install ``meshio`` with ``pip install
meshio`` if you wish to use it.

Parameters
----------
Expand Down Expand Up @@ -635,7 +637,13 @@ def from_meshio(mesh):

def read_meshio(filename, file_format=None):
"""Read any mesh file using meshio."""
import meshio
try:
import meshio
except ImportError: # pragma: no cover
raise ImportError(
"To use this feature install meshio with:\n\n"
"pip install meshio"
)

# Make sure relative paths will work
filename = os.path.abspath(os.path.expanduser(str(filename)))
Expand Down Expand Up @@ -673,7 +681,14 @@ def save_meshio(filename, mesh, file_format=None, **kwargs):
>>> pyvista.save_meshio('mymesh.inp', sphere) # doctest:+SKIP

"""
import meshio
try:
import meshio
except ImportError: # pragma: no cover
raise ImportError(
"To use this feature install meshio with:\n\n"
"pip install meshio"
)

from meshio.vtk._vtk import vtk_to_meshio_type

# Make sure relative paths will work
Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ param==1.10.1
ipygany
pytest-xdist
pythreejs
meshio>=4.0.3, <5.0
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
'pillow',
'appdirs',
'scooby>=0.5.1',
'meshio>=4.0.3, <5.0',
'vtk',
'dataclasses;python_version=="3.6"',
'typing_extensions;python_version<="3.7"',
Expand Down Expand Up @@ -70,6 +69,8 @@
python_requires='>=3.6.*',
install_requires=install_requires,
extras_require={
'colormaps': ['matplotlib', 'colorcet', 'cmocean']
'all': ['matplotlib', 'colorcet', 'cmocean', 'meshio'],
'colormaps': ['matplotlib', 'colorcet', 'cmocean'],
'io': ['meshio>=4.0.3, <5.0'],
},
)