Commit e3d5094a authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Replaced 'importlib.util.find_spec' with 'pkgutil.find_loader' to ensure...

Replaced 'importlib.util.find_spec' with 'pkgutil.find_loader' to ensure Python 2.7 compatibility. Updated minimal version of geoarray.
parent fdfeb162
Pipeline #3332 passed with stages
in 4 minutes and 27 seconds
......@@ -2,8 +2,8 @@
"""Top-level package for arosics."""
import warnings
from importlib import util
import warnings as _warnings
from pkgutil import find_loader as _find_loader
from arosics.CoReg import COREG
from arosics.CoReg_local import COREG_LOCAL
......@@ -22,7 +22,5 @@ __all__ = ['COREG',
# check optional dependencies
if not util.find_spec('pyfftw'):
warnings.warn('PYFFTW library is missing. However, coregistration works. But in some cases it can be much slower.')
del util, warnings
if not _find_loader('pyfftw'):
_warnings.warn('PYFFTW library is missing. However, coregistration works. But in some cases it can be much slower.')
......@@ -5,7 +5,8 @@
from setuptools import setup, find_packages
import warnings
from importlib import util
from pkgutil import find_loader
with open('README.rst') as readme_file:
readme = readme_file.read()
......@@ -17,7 +18,7 @@ version = {}
with open("arosics/version.py") as version_file:
exec(version_file.read(), version)
requirements = ['numpy', 'gdal', 'shapely', 'scikit-image', 'matplotlib', 'geopandas', 'geoarray>=0.8.0',
requirements = ['numpy', 'gdal', 'shapely', 'scikit-image', 'matplotlib', 'geopandas', 'geoarray>=0.8.8',
'py_tools_ds>=0.13.7', 'plotly', 'cmocean', 'six', 'folium>=0.6.0', 'geojson'
# 'pykrige' # conda install --yes -c conda-forge pykrige
# 'pyfftw', # conda install --yes -c conda-forge pyfftw=0.10.4 ; \
......@@ -66,16 +67,16 @@ setup(
# check for pyfftw
if not util.find_spec('pyfftw'):
if not find_loader('pyfftw'):
warnings.warn('You need to install pyfftw manually (see https://pypi.python.org/pypi/pyFFTW) for speeding up '
'the computation. It is not automatically installed.')
# check for basemap
if not util.find_spec('mpl_toolkits.basemap'):
if not find_loader('mpl_toolkits.basemap'):
warnings.warn('You need to install basemap manually if you want to plot maps (see www./matplotlib.org/basemap). '
'It is not automatically installed.')
# check for pykrige
if not util.find_spec('pykrige'):
if not find_loader('pykrige'):
warnings.warn('You need to install pykrige manually if you want to interpolate tie point grids produced by AROSICS '
'(see https://github.com/bsmurphy/PyKrige). It is not automatically installed.')
......@@ -46,5 +46,5 @@ dependencies:
- rednose
- cmocean
- plotly
- geoarray>=0.8.0
- geoarray>=0.8.8
- py_tools_ds>=0.13.7
......@@ -6,7 +6,7 @@
import unittest
import shutil
import os
from importlib import util
from pkgutil import find_loader
# custom
from .cases import test_cases
......@@ -64,12 +64,12 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
CRL.CoRegPoints_table
# test tie point grid visualization
if util.find_spec('mpl_toolkits.basemap'): # only works if basemap is installed
if find_loader('mpl_toolkits.basemap'): # only works if basemap is installed
CRL.view_CoRegPoints(hide_filtered=True)
CRL.view_CoRegPoints(hide_filtered=False)
CRL.view_CoRegPoints(shapes2plot='vectors')
if util.find_spec('folium') and util.find_spec('geojson'):
if find_loader('folium') and find_loader('geojson'):
CRL.view_CoRegPoints_folium()
# test shift correction and output writer
......
......@@ -6,7 +6,7 @@
import unittest
import tempfile
import os
from importlib import util
from pkgutil import find_loader
import shutil
# custom
......@@ -88,7 +88,7 @@ class Test_Tie_Point_Grid(unittest.TestCase):
self.assertTrue(os.path.isfile(outpath))
def test_to_Raster_using_Kriging(self):
if util.find_spec('pykrige.ok'):
if find_loader('pykrige.ok'):
with tempfile.TemporaryDirectory() as tmpdir:
outpath = os.path.join(tmpdir, 'X_SHIFT_M__interpolated.bsq')
self.TPG.to_Raster_using_Kriging(attrName='X_SHIFT_M', fName_out=outpath)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment