diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b699aa7ad07398a23c210cee5c0de6a73543c8c7..82ead0ade3146326b252274de233f3a71d1b3dbe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,11 +58,15 @@ test_py_tools_ds_install: - conda create -y -q --name py_tools_ds_testinstall python=3 - source activate py_tools_ds_testinstall + # update conda and python + - conda update -n base -c defaults conda +# - conda update -c conda-forge python + # avoid package incompatibilities due to usage of wrong channels - conda config --set channel_priority strict # otherwise gdal or libgdal may be installed from defaults channel # resolve some requirements with conda - - conda install --yes -q -c conda-forge numpy gdal scikit-image pyproj rasterio shapely geopandas + - conda install --yes -q -c conda-forge numpy gdal pyproj shapely geopandas # run installer - python setup.py install @@ -130,7 +134,7 @@ deploy_anaconda: script: - source /root/miniconda3/bin/activate - source activate ci_env - - conda install -y -q conda-build anaconda-client + - conda install -y -q conda-build conda-build-all anaconda-client - yum install -y patch # https://stackoverflow.com/questions/40392161/building-conda-skeleton-from-pypi-package-throws-error # - conda skeleton pypi py_tools_ds --output-dir public/conda.recipe/py_tools_ds # create recipe - conda config --set anaconda_upload yes # enable auto-upload to anaconda diff --git a/README.rst b/README.rst index 0b67a97fe1f896f7d6c078bb273fef7553768917..1e5e9bc0627765d2cddacef32d356d0d2a9469fa 100644 --- a/README.rst +++ b/README.rst @@ -62,7 +62,7 @@ Using conda_, the recommended approach is: # create virtual environment for py_tools_ds, this is optional conda create -y -q --name py_tools_ds python=3 source activate py_tools_ds - conda install -c conda-forge numpy gdal scikit-image pyproj rasterio shapely pandas + conda install -c conda-forge numpy gdal pyproj shapely scikit-image pandas Then install py_tools_ds using the pip installer: diff --git a/conda_recipe/meta.yaml b/conda_recipe/meta.yaml index 482cd5922561bd48ccddcc505d369e31f25c3ae5..a981b6265b86108dcf76062ba6a4aa01913ef47f 100644 --- a/conda_recipe/meta.yaml +++ b/conda_recipe/meta.yaml @@ -22,13 +22,10 @@ requirements: - sphinx-argparse run: - python - - pyqt - numpy - gdal - - scikit-image - - rasterio - pyproj - - lxml + - scikit-image - geopandas - six - spectral diff --git a/py_tools_ds/geo/raster/reproject.py b/py_tools_ds/geo/raster/reproject.py index cd8ee2abfb8fe5caf0cd09a11c919b16a3cd3314..b499db8ede3347c16083bb6fca96657411740307 100755 --- a/py_tools_ds/geo/raster/reproject.py +++ b/py_tools_ds/geo/raster/reproject.py @@ -24,6 +24,7 @@ import numpy as np import warnings import multiprocessing +from pkgutil import find_loader # custom try: @@ -44,9 +45,9 @@ from ...compatibility.gdal import get_gdal_func __author__ = "Daniel Scheffler" -def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=None, outUL=None, out_res=None, - out_extent=None, out_dtype=None, rsp_alg=0, in_nodata=None, out_nodata=None, - outExtent_within=True): # pragma: no cover +def warp_ndarray_rasterio(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=None, outUL=None, out_res=None, + out_extent=None, out_dtype=None, rsp_alg=0, in_nodata=None, out_nodata=None, + outExtent_within=True): # pragma: no cover """Reproject / warp a numpy array with given geo information to target coordinate system. :param ndarray: numpy.ndarray [rows,cols,bands] @@ -71,6 +72,11 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N :return out_gt: warped gdal GeoTransform :return out_prj: warped projection as WKT string """ + + if not find_loader('rasterio'): + raise ImportError('This function requires rasterio. You need to install it manually ' + '(conda install -c conda-forge rasterio). It is not automatically installed.') + # NOTE: rasterio seems to increase the number of objects with static TLS # There is a maximum number and if this is exceeded an ImportError is raised: # ImportError: dlopen: cannot load any more object with static TLS diff --git a/py_tools_ds/version.py b/py_tools_ds/version.py index b780f72f3cb64adcaa830203a2c89577a7424056..3e9ea2fe03426e1e0d59f96c5dcc11fca072a63f 100644 --- a/py_tools_ds/version.py +++ b/py_tools_ds/version.py @@ -19,5 +19,5 @@ # You should have received a copy of the GNU Lesser General Public License along # with this program. If not, see . -__version__ = '0.14.24' -__versionalias__ = '20200107_01' +__version__ = '0.14.25' +__versionalias__ = '20200108_01' diff --git a/requirements.txt b/requirements.txt index d73872b76d0a7e26beaa3aff173c88d7d24aaaab..222307375d36c0ca5190dba0fd338fec6e13e48b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,9 +3,8 @@ kealib # fix for libkea.so.1.4.7: cannot open shared object file: No such file numpy shapely six -rasterio +scikit-image pandas geopandas -scikit-image pyproj spectral diff --git a/setup.py b/setup.py index c1ca2136eea162b45d6923ff963412e359122dfc..5abf04f9967655f34b809cc524d3396ee66e2b9e 100644 --- a/setup.py +++ b/setup.py @@ -36,8 +36,7 @@ version = {} with open("py_tools_ds/version.py") as version_file: exec(version_file.read(), version) -requirements = ['gdal', 'numpy', 'shapely', 'six', 'rasterio', 'pandas', 'geopandas', - 'scikit-image', 'pyproj', 'spectral'] +requirements = ['gdal', 'numpy', 'shapely', 'six', 'pandas', 'scikit-image', 'geopandas', 'pyproj', 'spectral'] setup_requirements = [] # TODO(danschef): put setup requirements (distutils extensions, etc.) here test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose"] @@ -69,8 +68,10 @@ setup( 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', ], test_suite='tests', tests_require=test_requirements, - setup_requires=setup_requirements + setup_requires=setup_requirements, + extras_require={'rio_reproject': ["rasterio"]} ) diff --git a/tests/CI_docker/context/environment_py_tools_ds.yml b/tests/CI_docker/context/environment_py_tools_ds.yml index 9f696bf5cc096216edf2661add60b23c1750a270..7f1caa56f6abb94e492699ada76ac4df234229b5 100644 --- a/tests/CI_docker/context/environment_py_tools_ds.yml +++ b/tests/CI_docker/context/environment_py_tools_ds.yml @@ -5,20 +5,14 @@ channels: &id1 dependencies: - python=3.*.* - - pyqt + - pip # avoids that conda uses the wrong pip - numpy - gdal - conda-forge::libgdal # force to use conda-forge for libgdal to avoid package version incompatiblies due to mixed channels (libkea.so.1.4.7: cannot open shared object file: No such file or directory) # - kealib # fix for libkea.so.1.4.7: cannot open shared object file: No such file or directory (not needed as long as libgdal and gdal are conda-forge packages) - - scikit-image - - rasterio - pyproj - - lxml + - scikit-image - geopandas - - ipython - - conda-build # for conda deployment - - conda-build-all - - anaconda-client # for conda upload - pip: - sphinx-argparse - six diff --git a/tests/CI_docker/context/py_tools_ds_ci.docker b/tests/CI_docker/context/py_tools_ds_ci.docker index 7f1d8cace1446c9307f76a7acd84a6fa98bf090f..64b5a0c5599b073cb8cb55672a938b8c6362e274 100644 --- a/tests/CI_docker/context/py_tools_ds_ci.docker +++ b/tests/CI_docker/context/py_tools_ds_ci.docker @@ -6,7 +6,9 @@ RUN yum update -y && \ COPY *.yml /root/ # update the ci_env environment (that already contains all packages installed via 'docker_pyenvs' repo) +# -> also include packages for conda deployment and upload RUN /bin/bash -i -c "\ source /root/miniconda3/bin/activate ; \ source activate ci_env; \ - conda env update -n ci_env -f /root/environment_py_tools_ds.yml" + conda env update -n ci_env -f /root/environment_py_tools_ds.yml ; \ + conda install -c conda-forge conda-build conda-build-all anaconda-client"