diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 9d640c5..8fad0f5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -9,12 +9,18 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, ubuntu-20.04] - python-version: ['3.11', '3.10', '3.9', '3.8', '3.7', '3.6'] - gdal-version: ['3.4'] #, '3.6'] TODO: gdal 3.6 is still unstable. + os: [ubuntu-22.04, ubuntu-20.04] # no ubuntugis @ ubuntu-24.04 + python-version: ['3.11', '3.10', '3.9', '3.8', '3.7'] # , '3.6'] <- 3.6 needs setup.cfg + gdal-version: ['3.4', '3.6'] # TODO: gdal 3.6 is still unstable. exclude: + - os: ubuntu-24.04 + python-version: '3.8' + - os: ubuntu-24.04 + python-version: '3.7' + - os: ubuntu-24.04 + gdal-version: '3.4' - os: ubuntu-22.04 - python-version: '3.6' + gdal-version: '3.4' - os: ubuntu-20.04 python-version: '3.11' - os: ubuntu-20.04 @@ -27,6 +33,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: install gdal + id: gdal run: | if [ "${{ matrix.os }}" = "ubuntu-20.04" ] then @@ -43,20 +50,16 @@ jobs: echo "using version ->${APT_GDAL_VERSION}<-" apt-cache madison libgdal30 | grep "${APT_GDAL_VERSION}" && sudo apt-get install libgdal30="${APT_GDAL_VERSION}" sudo apt-get install python3-gdal="${APT_GDAL_VERSION}" libgdal-dev="${APT_GDAL_VERSION}" + echo gdal_version=$(echo "${APT_GDAL_VERSION}" | cut -f1 -d '+') >> $GITHUB_OUTPUT - name: Install dependencies for test run: | python -m pip install --upgrade pip wheel python -m pip install setuptools==57.* python -m pip freeze - if [ "${{ matrix.python-version }}" == "3.6" ] - then - echo "hack setup.cfg to accomodate python version <= 3.6" - sed -i 's/geopackage_validator.__version__/0.0.0/g' setup.cfg - fi - name: Install dependencies from config run: | # we need to pin GDAL here to match the python3-gdal - pip install GDAL==${{ matrix.gdal-version }} + pip install GDAL==${{steps.gdal.outputs.gdal_version}} pip3 install --no-cache-dir .[test] - name: Test with pytest run: | diff --git a/.gitignore b/.gitignore index 569579f..0f27ff8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ node_modules/ doc/build/ ansible/*.retry .venv +/venv/ build/ # Unit test / coverage reports @@ -33,4 +34,4 @@ coverage.xml # Docker docker-compose.override.yml -.env \ No newline at end of file +.env diff --git a/Dockerfile b/Dockerfile index 22e004e..559717c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ WORKDIR /code COPY ./geopackage_validator /code/geopackage_validator COPY ./pyproject.toml /code/pyproject.toml -COPY ./setup.cfg /code/setup.cfg COPY ./setup.py /code/setup.py # --- TEST-IMAGE --- diff --git a/Dockerfile.local b/Dockerfile.local index 894259a..960d24c 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -11,21 +11,19 @@ ARG GROUP_ID=1000 ARG USER_NAME=pdok ARG GROUP_NAME=pdok +RUN apk add --update --no-cache py3-pip + RUN addgroup -g $GROUP_ID $GROUP_NAME && \ adduser --shell /sbin/nologin --disabled-password \ --uid $USER_ID --ingroup $GROUP_NAME $USER_NAME USER $USER_NAME -ENV VIRTUAL_ENV=/home/pdok/venv -RUN python3 -m venv --system-site-packages /home/pdok/venv -ENV PATH="$VIRTUAL_ENV/bin:$PATH" +ENV PYTHONUNBUFFERED=1 RUN pip3 install setuptools pip virtualenv --upgrade COPY --chown=pdok:pdok . /code WORKDIR /code -RUN . /home/pdok/venv/bin/activate && pip3 install -e .[test] - ADD local_entrypoint.sh /entry/local_entrypoint.sh ENTRYPOINT [ "/entry/local_entrypoint.sh" ] diff --git a/geopackage_validator/validations/geometry_dimension_check.py b/geopackage_validator/validations/geometry_dimension_check.py index 6f0e1bd..fe53d42 100644 --- a/geopackage_validator/validations/geometry_dimension_check.py +++ b/geopackage_validator/validations/geometry_dimension_check.py @@ -25,9 +25,13 @@ def query_dimensions(dataset) -> Iterable[Tuple[str, str]]: validations = dataset.ExecuteSQL( DIMENSION_QUERY.format(table_name=table_name, geom_column_name=column_name) ) + validation_list = ( + [] + if validations is None + else [(z, m, ndims) for z, m, ndims in validations] + ) - if validations is not None: - validation_list = [(z, m, ndims) for z, m, ndims in validations] + if validation_list: four_dimensions = all(ndims == 4 for z, m, ndims in validation_list) m_coordinates_all_0 = all(m for z, m, ndims in validation_list) z_coordinates_all_0 = all(z for z, m, ndims in validation_list) diff --git a/local_entrypoint.sh b/local_entrypoint.sh index 03493a5..ac1b844 100755 --- a/local_entrypoint.sh +++ b/local_entrypoint.sh @@ -1,8 +1,11 @@ #!/usr/bin/env sh - # this entrypoint does just that: make sure the egg-info dir is available by installing (again) with pip. -if [ ! -d ./pdok_geopackage_validator.egg-info/ ] +if [ ! -d /code/pdok_geopackage_validator.egg-info/ ] || [ ! -d /code/venv/ ] then - pip3 install --no-cache-dir -e . + python3 -m venv --system-site-packages /code/venv + . /code/venv/bin/activate + pip3 install -e .[test] +else + . /code/venv/bin/activate fi exec "$@" diff --git a/pyproject.toml b/pyproject.toml index 19cf58e..56e5aba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,28 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", ] -dynamic = ["version", "readme", "requires-python"] +dynamic = ["version", "readme"] +dependencies = [ + "setuptools>=42.0,!=58.*,!=59.*,!=60.*,!=61.*", + "Click >= 8.0", + "click-log >=0.3", + "gdal >=3.0.4", + "minio", + "pyyaml", +] +requires-python = ">=3.6" + +[project.optional-dependencies] +test = [ + "black == 22.3.0", + "flake8", + "ipdb", + "ipython", + "pytest >= 7.0.1", + "pytest-cov", + "pytest-flakes", + "pytest-mock" +] [project.scripts] geopackage-validator = "geopackage_validator.cli:cli" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c72ea1d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,40 +0,0 @@ -[metadata] -name = pdok_geopackage_validator -version = 0.0.0 -description = "Validate Geopackage files according to PDOK requirements and recommendations" -keywords = ["geopackage-validator", "geopackage", "pdok"] -license = {text = "MIT"} -classifiers = - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9" - -[options] -python_requires = >=3.6 -install_requires = - setuptools>=42.0,!=58.*,!=59.*,!=60.*,!=61.* - Click >= 8.0 - click-log >=0.3 - gdal >=3.0.4 - minio - pyyaml - -[options.extras_require] -test = - black == 22.3.0 - flake8 - ipdb - ipython - pytest >= 7.0.1 - pytest-cov - pytest-flakes - pytest-mock - -[tool:pytest] -addopts = --cache-clear -filterwarnings = - ignore:the imp module is deprecated in favour of importlib.*:DeprecationWarning - ignore:Using or importing the ABCs from 'collections' instead of from.*:DeprecationWarning