Commit 69907bc6 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed all dead URLs. Removed travis related files. Re-ordered dependencies.

*Added Python 3.9 classifier to and removed those for <3.6.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <>
parent 819f34df
Pipeline #16655 passed with stage
in 1 minute and 11 seconds
......@@ -48,8 +48,8 @@ test_urls:
stage: test
- source /root/miniconda3/bin/activate ci_env
- pip install urlchecker
- urlchecker check . --file-types .py,.rst,.md,.json
- pip install -U urlchecker
- make urlcheck
when: always
# Config file for automatic testing at
# This file will be regenerated if you run
language: python
python: 3.5
- TOXENV=py35
- TOXENV=py34
- TOXENV=py33
- TOXENV=py27
- TOXENV=py26
- TOXENV=pypy
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install -U tox
# command to run tests, e.g. python test
script: tox -e ${TOXENV}
# After you create the Github repo and add it to Travis, run the
# script to finish PyPI deployment setup
provider: pypi
distributions: sdist bdist_wheel
user: danschef
tags: true
repo: danschef/py_tools_ds
condition: $TOXENV == py27
......@@ -2,6 +2,15 @@
0.16.5 (2020-12-09)
* Added URL checker CI job and fixed all dead URLs.
* Removed travis related files.
* Re-ordered dependencies.
* Added Python 3.9 classifier to and removed those for <3.6.
0.16.4 (2020-12-07)
......@@ -56,6 +56,9 @@ lint: ## check style with flake8
pycodestyle py_tools_ds --exclude="*.ipynb,*.ipynb*" --max-line-length=120 > ./tests/linting/pycodestyle.log
-pydocstyle py_tools_ds > ./tests/linting/pydocstyle.log
urlcheck: ## check for dead URLs
urlchecker check . --file-types .py,.rst,.md,.json
test: ## run tests quickly with the default Python
python test
......@@ -12,17 +12,6 @@ A collection of Python tools by Daniel Scheffler.
.. .. image::
.. .. image::
:alt: Documentation Status
.. .. image::
:alt: Updates
.. image::
.. image::
......@@ -63,13 +63,13 @@ def transform_wgs84_to_utm(lon, lat, zone=None):
def transform_any_prj(prj_src, prj_tgt, x, y):
# type: (Union[str, int], Union[str, int], float, float) -> (float, float)
# type: (Union[str, int], Union[str, int], Union[float, np.ndarray], Union[float, np.ndarray]) -> (Union[float, np.ndarray], Union[float, np.ndarray]) # noqa
"""Transform X/Y data from any source projection to any target projection.
:param prj_src: GDAL projection as WKT string or EPSG code ('epsg:1234' or <EPSG_int>)
:param prj_tgt: GDAL projection as WKT string or EPSG code ('epsg:1234' or <EPSG_int>)
:param x:
:param y:
:param x: X-coordinate(s) to be transformed (either <float> or 1D-<np.ndarray>)
:param y: X-coordinate(s) to be transformed (either <float> or 1D-<np.ndarray>)
transformer = pyproj.Transformer.from_crs(pyproj.CRS.from_user_input(prj_src),
......@@ -284,7 +284,7 @@ def warp_ndarray(ndarray, in_gt, in_prj=None, out_prj=None, out_dtype=None,
:param options: <str> additional GDAL options as string, e.g. '-nosrcalpha' or '-order'
:param transformerOptions: <list> list of transformer options, e.g. ['SRC_SRS=invalid']
:param warpOptions: <list> list of warp options, e.g. ['CUTLINE_ALL_TOUCHED=TRUE'],
find available options here:
find available options here:
:param CPUs: <int> number of CPUs to use (default: None, which means 'all CPUs available')
:param warpMemoryLimit: <int> size of working buffer in bytes (default: 0)
:param progress: <bool> show progress bar (default: True)
......@@ -48,7 +48,7 @@ requirements = [
setup_requirements = ['setuptools']
test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose", "shapely"]
test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose", "shapely", "urlchecker"]
......@@ -72,12 +72,10 @@ setup(
'Natural Language :: English',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
......@@ -6,21 +6,24 @@ channels: &id1
- python=3.*.*
- pip # avoids that conda uses the wrong pip
- numpy
- gdal>=2.1.0
- geopandas
- numpy
- pyproj>=2.2.0
- scikit-image
- geopandas
- pip:
- sphinx-argparse
- six
- spectral
- coverage
- flake8
- pycodestyle
- pylint
- pydocstyle
- nose
- nose2
- nose-htmloutput
- coverage
- pycodestyle
- pydocstyle
- pylint
- rednose
- sphinx-argparse
- urlchecker
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# py_tools_ds
# Copyright (C) 2019 Daniel Scheffler (GFZ Potsdam,
# 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 <>.
"""Update encrypted deploy password in Travis config file
from __future__ import print_function
import base64
import json
import os
from getpass import getpass
import yaml
from cryptography.hazmat.primitives.serialization import load_pem_public_key
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15
from urllib import urlopen
except ImportError:
from urllib.request import urlopen
GITHUB_REPO = 'danschef/py_tools_ds'
TRAVIS_CONFIG_FILE = os.path.join(
os.path.dirname(os.path.abspath(__file__)), '.travis.yml')
def load_key(pubkey):
"""Load public RSA key, with work-around for keys using
incorrect header/footer format.
Read more about RSA encryption with cryptography:
return load_pem_public_key(pubkey.encode(), default_backend())
except ValueError:
# workaround for
pubkey = pubkey.replace('BEGIN RSA', 'BEGIN').replace('END RSA', 'END')
return load_pem_public_key(pubkey.encode(), default_backend())
def encrypt(pubkey, password):
"""Encrypt password using given RSA public key and encode it with base64.
The encrypted password can only be decrypted by someone with the
private key (in this case, only Travis).
key = load_key(pubkey)
encrypted_password = key.encrypt(password, PKCS1v15())
return base64.b64encode(encrypted_password)
def fetch_public_key(repo):
"""Download RSA public key Travis will use for this repo.
Travis API docs:
keyurl = '{0}/key'.format(repo)
data = json.loads(urlopen(keyurl).read().decode())
if 'key' not in data:
errmsg = "Could not find public key for repo: {}.\n".format(repo)
errmsg += "Have you already added your GitHub repo to Travis?"
raise ValueError(errmsg)
return data['key']
def prepend_line(filepath, line):
"""Rewrite a file adding a line to its beginning.
with open(filepath) as f:
lines = f.readlines()
lines.insert(0, line)
with open(filepath, 'w') as f:
def load_yaml_config(filepath):
with open(filepath) as f:
return yaml.load(f)
def save_yaml_config(filepath, config):
with open(filepath, 'w') as f:
yaml.dump(config, f, default_flow_style=False)
def update_travis_deploy_password(encrypted_password):
"""Update the deploy section of the .travis.yml file
to use the given encrypted password.
config = load_yaml_config(TRAVIS_CONFIG_FILE)
config['deploy']['password'] = dict(secure=encrypted_password)
save_yaml_config(TRAVIS_CONFIG_FILE, config)
line = ('# This file was autogenerated and will overwrite'
' each time you run\n')
prepend_line(TRAVIS_CONFIG_FILE, line)
def main(args):
public_key = fetch_public_key(args.repo)
password = args.password or getpass('PyPI password: ')
update_travis_deploy_password(encrypt(public_key, password.encode()))
print("Wrote encrypted password to .travis.yml -- you're ready to deploy")
if '__main__' == __name__:
import argparse
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--repo', default=GITHUB_REPO,
help='GitHub repo (default: %s)' % GITHUB_REPO)
help='PyPI password (will prompt if not provided)')
args = parser.parse_args()
Supports Markdown
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