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

* Dropped Python 2.7 support due to end-of-life status.


* Dropped compatibility module since this was Python 2.7 specific.
* Dropped requirements six and packaging.
* Updated minimal version of pyproj to 2.5.0.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent d80f29a5
Pipeline #22782 failed with stage
in 1 minute and 42 seconds
......@@ -20,7 +20,6 @@ test_py_tools_ds:
stage: test
script:
- source /root/miniconda3/bin/activate ci_env
- pip install packaging # TODO remove when CI runner is rebuilt
- make nosetests
- make docs
artifacts:
......@@ -69,7 +68,7 @@ test_py_tools_ds_install:
# - 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 'pyproj>=2.1.0' shapely geopandas
- conda install --yes -q -c conda-forge numpy gdal 'pyproj>=2.5.0' shapely geopandas
# run installer
- python setup.py install
......
......@@ -101,7 +101,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check
3. The pull request should work for Python 3.6, 3.7, 3.8. 3.9, and for PyPy. Check
https://travis-ci.org/danschef/py_tools_ds/pull_requests
and make sure that the tests pass for all supported Python versions.
......
......@@ -2,12 +2,17 @@
History
=======
0.16.10 (2021-05-07)
0.17.0 (2021-05-07)
--------------------
* Added test and test data for geo.raster.conversion.raster2polygon().
* Replaced skimage downsampling by GDAL variant.
* Removed scikit-learn dependency.
* Removed scikit-image dependency.
* Dropped Python 2.7 support due to end-of-life status.
* Dropped compatibility module since this was Python 2.7 specific.
* Dropped requirements six and packaging.
* Added some docs/.rst files to .gitignore.
* Updated minimal version of pyproj to 2.5.0.
0.16.9 (2021-05-07)
......
# -*- coding: utf-8 -*-
# py_tools_ds
#
# Copyright (C) 2019 Daniel Scheffler (GFZ Potsdam, daniel.scheffler@gfz-potsdam.de)
#
# This software was developed within the context of the GeoMultiSens project funded
# by the German Federal Ministry of Education and Research
# (project grant code: 01 IS 14 010 A-C).
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
__author__ = 'Daniel Scheffler'
# -*- coding: utf-8 -*-
# py_tools_ds
#
# Copyright (C) 2019 Daniel Scheffler (GFZ Potsdam, daniel.scheffler@gfz-potsdam.de)
#
# This software was developed within the context of the GeoMultiSens project funded
# by the German Federal Ministry of Education and Research
# (project grant code: 01 IS 14 010 A-C).
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
__author__ = 'Daniel Scheffler'
# -*- coding: utf-8 -*-
# py_tools_ds
#
# Copyright (C) 2019 Daniel Scheffler (GFZ Potsdam, daniel.scheffler@gfz-potsdam.de)
#
# This software was developed within the context of the GeoMultiSens project funded
# by the German Federal Ministry of Education and Research
# (project grant code: 01 IS 14 010 A-C).
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
__author__ = "Daniel Scheffler"
class TimeoutError(OSError):
"""Timeout expired."""
class FileNotFoundError(OSError):
"""File not found."""
# -*- coding: utf-8 -*-
# py_tools_ds
#
# Copyright (C) 2019 Daniel Scheffler (GFZ Potsdam, daniel.scheffler@gfz-potsdam.de)
#
# This software was developed within the context of the GeoMultiSens project funded
# by the German Federal Ministry of Education and Research
# (project grant code: 01 IS 14 010 A-C).
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import
import os
import errno
from six import PY3
__author__ = "Daniel Scheffler"
def makedirs(name, exist_ok=False, **kwargs):
if PY3:
os.makedirs(name, exist_ok=exist_ok, **kwargs)
else:
try:
os.makedirs(name)
except OSError as e:
if e.errno != errno.EEXIST:
raise
......@@ -27,7 +27,6 @@ import sqlite3
import os
from typing import Union # noqa F401 # flake8 issue
import csv
from six import PY3
def data_DB_updater(gms_obj_dict, path_db):
......@@ -112,7 +111,7 @@ def SQL_DB_to_csv(path_db):
cursor = connection.cursor()
cursor.execute("SELECT * FROM processed_data")
with open(os.path.join(os.path.dirname(path_db), 'data_DB.csv'), 'w' if PY3 else 'wb') as csvfile:
with open(os.path.join(os.path.dirname(path_db), 'data_DB.csv'), 'w') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow([i[0] for i in cursor.description])
csvwriter.writerows(cursor)
# -*- coding: utf-8 -*-
# py_tools_ds
#
# Copyright (C) 2019 Daniel Scheffler (GFZ Potsdam, daniel.scheffler@gfz-potsdam.de)
#
# This software was developed within the context of the GeoMultiSens project funded
# by the German Federal Ministry of Education and Research
# (project grant code: 01 IS 14 010 A-C).
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
__author__ = 'Daniel Scheffler'
......@@ -84,17 +84,11 @@ def prj_equal(prj1, prj2):
if prj1 is None and prj2 is None or prj1 == prj2:
return True
else:
from pyproj import __version__ as ver
from packaging.version import parse
if parse(ver) >= parse('2.5'):
# CRS.equals was added in pyproj 2.5 which does not exist for Python 2.7 in conda-forge channel
crs1 = CRS.from_user_input(prj1)
crs2 = CRS.from_user_input(prj2)
# CRS.equals was added in pyproj 2.5
crs1 = CRS.from_user_input(prj1)
crs2 = CRS.from_user_input(prj2)
return crs1.equals(crs2)
else:
return get_proj4info(proj=prj1) == get_proj4info(proj=prj2)
return crs1.equals(crs2)
def isProjectedOrGeographic(prj):
......
......@@ -23,14 +23,11 @@
__author__ = "Daniel Scheffler"
from six import PY3
from shapely.wkb import loads
from osgeo import gdal, osr, ogr
from ...io.raster.gdal import get_GDAL_ds_inmem
from ...processing.progress_mon import ProgressBar, Timer
from ...compatibility.python.exceptions import TimeoutError as TimeoutError_comp
from ..raster.reproject import warp_ndarray
......@@ -81,16 +78,16 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
use_as_callback=True) \
if progress and not q else Timer(timeout, use_as_callback=True) if timeout else None
# run the algorithm
status = gdal.Polygonize(src_band, src_band.GetMaskBand(), mem_layer, 0, ["8CONNECTED=8"] if exact else [],
callback=callback)
# run the algorithm
status = gdal.Polygonize(src_band, src_band.GetMaskBand(), mem_layer, 0, ["8CONNECTED=8"] if exact else [],
callback=callback)
# handle exit status other than 0 (fail)
if status != 0:
errMsg = gdal.GetLastErrorMsg()
if errMsg == 'User terminated':
raise TimeoutError('raster2polygon timed out!') if PY3 else TimeoutError_comp('raster2polygon timed out!')
raise Exception(errMsg)
# handle exit status other than 0 (fail)
if status != 0:
errMsg = gdal.GetLastErrorMsg()
if errMsg == 'User terminated':
raise TimeoutError('raster2polygon timed out!')
raise Exception(errMsg)
# extract polygon
mem_layer.SetAttributeFilter('DN = %s' % DN2extract)
......@@ -127,7 +124,7 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
GDF.loc[i] = [loads(element.GetGeometryRef().ExportToWkb()).buffer(0), DN2extract]
del element
else:
raise TimeoutError('raster2polygon timed out!') if PY3 else TimeoutError_comp('raster2polygon timed out!')
raise TimeoutError('raster2polygon timed out!')
GDF = GDF.dissolve(by='DN')
......
# -*- coding: utf-8 -*-
from six import PY3
import json
import socket
if PY3:
# noinspection PyCompatibility
from urllib.request import urlopen
else:
from urllib import urlopen
from urllib.request import urlopen
def get_geoinfo():
......
......@@ -40,11 +40,9 @@ requirements = [
'gdal>=2.1.0',
'geopandas',
'numpy',
'packaging', # remove when dropping Python 2.7 support
'pandas',
'pyproj>=2.2.0',
'pyproj>=2.5.0',
'shapely',
'six',
'spectral'
]
setup_requirements = ['setuptools']
......@@ -71,7 +69,6 @@ setup(
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Natural Language :: English',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
......
......@@ -9,12 +9,10 @@ dependencies:
- gdal>=2.1.0
- geopandas
- numpy
- pyproj>=2.2.0
- pyproj>=2.5.0
- shapely
- pip:
- packaging
- six
- spectral
- coverage
......
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