diff --git a/.github/workflows/pip-checks.yml b/.github/workflows/pip-checks.yml new file mode 100644 index 00000000..ecb4e2fe --- /dev/null +++ b/.github/workflows/pip-checks.yml @@ -0,0 +1,49 @@ +# This workflow checks that pip installation works to import the package (tests are in python-tests.yml) + +name: pip-install + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: ${{ matrix.os }}, python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + python-version: ["3.9", "3.10", "3.11"] + + # Run all shells using bash (including Windows) + defaults: + run: + shell: bash -l {0} + + steps: + - uses: actions/checkout@v4 + + # We initiate the environment empty + - name: Initiate empty environment + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + auto-update-conda: true + use-mamba: true + channel-priority: strict + activate-environment: xdem-pip + python-version: + + # Use pip install + - name: Install project + run: | + mamba install pip + pip install -e . + + # Check import works + - name: Check import works with base environment + run: python -c "import xdem" diff --git a/dev-environment.yml b/dev-environment.yml index 517056b9..bcdeac8d 100644 --- a/dev-environment.yml +++ b/dev-environment.yml @@ -13,7 +13,7 @@ dependencies: - tqdm - scikit-image=0.* - scikit-gstat>=1.0,<1.1 - - geoutils=0.1.7 + - geoutils=0.1.8 # Development-specific, to mirror manually in setup.cfg [options.extras_require]. - pip diff --git a/environment.yml b/environment.yml index 1202fb91..368cb74a 100644 --- a/environment.yml +++ b/environment.yml @@ -13,7 +13,7 @@ dependencies: - tqdm - scikit-image=0.* - scikit-gstat>=1.0,<1.1 - - geoutils=0.1.7 + - geoutils=0.1.8 - pip # To run CI against latest GeoUtils diff --git a/requirements.txt b/requirements.txt index 210e92cc..3a813b79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,5 +11,5 @@ scipy>=1.0,<1.13 tqdm scikit-image==0.* scikit-gstat>=1.0,<1.1 -geoutils==0.1.7 +geoutils==0.1.8 pip diff --git a/tests/test_misc.py b/tests/test_misc.py index fc87a314..8c990fdd 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -118,8 +118,8 @@ def useless_func() -> int: def test_diff_environment_yml(self, capsys) -> None: # type: ignore # Test with synthetic environment - env = {"dependencies": ["python==3.9", "numpy", "fiona"]} - devenv = {"dependencies": ["python==3.9", "numpy", "fiona", "opencv"]} + env = {"dependencies": ["python==3.9", "numpy", "pandas"]} + devenv = {"dependencies": ["python==3.9", "numpy", "pandas", "opencv"]} # This should print the difference between the two xdem.misc.diff_environment_yml(env, devenv, input_dict=True, print_dep="conda") @@ -134,8 +134,8 @@ def test_diff_environment_yml(self, capsys) -> None: # type: ignore captured = capsys.readouterr().out assert captured == "opencv\nNone\n" - env2 = {"dependencies": ["python==3.9", "numpy", "fiona"]} - devenv2 = {"dependencies": ["python==3.9", "numpy", "fiona", "opencv", {"pip": ["geoutils", "-e ./"]}]} + env2 = {"dependencies": ["python==3.9", "numpy", "pandas"]} + devenv2 = {"dependencies": ["python==3.9", "numpy", "pandas", "opencv", {"pip": ["geoutils", "-e ./"]}]} # The diff function should not account for -e ./ that is the local install for developers xdem.misc.diff_environment_yml(env2, devenv2, input_dict=True, print_dep="both") @@ -155,13 +155,13 @@ def test_diff_environment_yml(self, capsys) -> None: # type: ignore # When the dependencies are not defined in dev-env but in env, it should raise an error # For normal dependencies - env3 = {"dependencies": ["python==3.9", "numpy", "fiona", "lol"]} - devenv3 = {"dependencies": ["python==3.9", "numpy", "fiona", "opencv", {"pip": ["geoutils"]}]} + env3 = {"dependencies": ["python==3.9", "numpy", "pandas", "lol"]} + devenv3 = {"dependencies": ["python==3.9", "numpy", "pandas", "opencv", {"pip": ["geoutils"]}]} with pytest.raises(ValueError, match="The following dependencies are listed in env but not dev-env: lol"): xdem.misc.diff_environment_yml(env3, devenv3, input_dict=True, print_dep="pip") # For pip dependencies - env4 = {"dependencies": ["python==3.9", "numpy", "fiona", {"pip": ["lol"]}]} - devenv4 = {"dependencies": ["python==3.9", "numpy", "fiona", "opencv", {"pip": ["geoutils"]}]} + env4 = {"dependencies": ["python==3.9", "numpy", "pandas", {"pip": ["lol"]}]} + devenv4 = {"dependencies": ["python==3.9", "numpy", "pandas", "opencv", {"pip": ["geoutils"]}]} with pytest.raises(ValueError, match="The following pip dependencies are listed in env but not dev-env: lol"): xdem.misc.diff_environment_yml(env4, devenv4, input_dict=True, print_dep="pip") diff --git a/xdem/coreg/base.py b/xdem/coreg/base.py index 94b1ab3f..1e685d8c 100644 --- a/xdem/coreg/base.py +++ b/xdem/coreg/base.py @@ -18,11 +18,11 @@ ) import affine -import fiona import geopandas as gpd import geoutils as gu import numpy as np import pandas as pd +import pyogrio import rasterio as rio import rasterio.warp # pylint: disable=unused-import import scipy @@ -272,8 +272,8 @@ def _mask_as_array(reference_raster: gu.Raster, mask: str | gu.Vector | gu.Raste # First try to load it as a Vector try: mask = gu.Vector(mask) - # If the format is unsopported, try loading as a Raster - except fiona.errors.DriverError: + # If the format is unsupported, try loading as a Raster + except pyogrio.errors.DataSourceError: try: mask = gu.Raster(mask) # If that fails, raise an error