Skip to content

Commit

Permalink
Add pre-commit, simplify Travis config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean C. Gillies committed Jul 18, 2018
1 parent 9fc96ab commit a26526d
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 53 deletions.
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
-
repo: https://github.com/ambv/black
rev: ed50737290662f6ef4016a7ea44da78ee1eff1e2
hooks:
- id: black
args: [--safe]
language_version: python3.6
-
repo: 'https://github.com/pre-commit/pre-commit-hooks'
# v1.3.0
rev: a6209d8d4f97a09b61855ea3f1fb250f55147b8b
hooks:
- id: flake8
args: [
# E501 let black handle all line length decisions
# W503 black conflicts with "line break before operator" rule
# E203 black conflicts with "whitespace before ':'" rule
'--ignore=E501,W503,E203']
-
repo: 'https://github.com/chewse/pre-commit-mirrors-pydocstyle'
# 2.1.1
rev: 22d3ccf6cf91ffce3b16caa946c155778f0cb20f
hooks:
- id: pydocstyle
args: [
# Check for docstring presence only
'--select=D1',
# Don't require docstrings for tests
'--match=(?!test).*\.py',
# Skip docstring check for dunder methods
--add-ignore=D105]
31 changes: 12 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
language: python

sudo: false

cache:
directories:
- ~/.cache/pip

env:
global:
- PIP_WHEEL_DIR=$HOME/.cache/pip/wheels
- PIP_FIND_LINKS=file://$HOME/.cache/pip/wheels
addons:
apt:
packages:
- libgdal1h
- gdal-bin
- libgdal-dev
- libatlas-dev
- libatlas-base-dev
- gfortran

python:
- "2.7"
- "3.6"

before_install:
- "pip install -U pip"
- "pip install wheel"
- pip install -U pip
- pip install -r requirements-dev.txt

install:
- "pip wheel numpy"
- "pip install --only-binary numpy numpy"
- "pip wheel -r requirements.txt"
- "pip install -r requirements.txt"
- "pip wheel -r requirements-dev.txt"
- "pip install -r requirements-dev.txt"
- "pip install -e .[test]"
- pip install -e .[test]

script:
- py.test --cov rio_color --cov-report term-missing
- pre-commit run --all-files && python -m pytest --cov rio_color --cov-report term-missing

after_success:
- coveralls
5 changes: 3 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
affine
cligj
coveralls>=0.4
colormath==2.0.2
coveralls>=0.4
cython==0.28.4
delocate
enum34
numpy>=1.8.0
snuggs>=1.2
pre-commit
pytest
setuptools>=0.9.8
snuggs>=1.2
wheel
67 changes: 35 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
include_dirs = []
try:
import numpy

include_dirs.append(numpy.get_include())
except ImportError:
print("Numpy and its headers are required to run setup(). Exiting.")
sys.exit(1)


# Parse the version from the fiona module.
with open('rio_color/__init__.py') as f:
with open("rio_color/__init__.py") as f:
for line in f:
if line.find("__version__") >= 0:
version = line.split("=")[1].strip()
Expand All @@ -39,55 +40,57 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()


if cythonize and 'clean' not in sys.argv:
ext_modules = cythonize([
Extension(
"rio_color.colorspace",
["rio_color/colorspace.pyx"],
extra_compile_args=["-O2"])])
if cythonize and "clean" not in sys.argv:
ext_modules = cythonize(
[
Extension(
"rio_color.colorspace",
["rio_color/colorspace.pyx"],
extra_compile_args=["-O2"],
)
]
)
else:
ext_modules = [
Extension(
"rio_color.colorspace", ["rio_color/colorspace.c"])]
ext_modules = [Extension("rio_color.colorspace", ["rio_color/colorspace.c"])]

inst_reqs = ["click", "rasterio>=1.0a11", "rio-mucho"]

if sys.version_info < (3, 4):
inst_reqs.append('enum34')
inst_reqs.append("enum34")

setup(
name='rio-color',
name="rio-color",
version=version,
description=u"Color correction plugin for rasterio",
long_description=long_description,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Cython',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Multimedia :: Graphics :: Graphics Conversion',
'Topic :: Scientific/Engineering :: GIS'],
keywords='',
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Cython",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
"Topic :: Scientific/Engineering :: GIS",
],
keywords="",
author=u"Charlie Loyd",
author_email='charlie@mapbox.com',
url='https://github.com/mapbox/rio-color',
license='BSD',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
author_email="charlie@mapbox.com",
url="https://github.com/mapbox/rio-color",
license="BSD",
packages=find_packages(exclude=["ez_setup", "examples", "tests"]),
include_package_data=True,
zip_safe=False,
install_requires=inst_reqs,
ext_modules=ext_modules,
include_dirs=include_dirs,
extras_require={
'test': ['pytest', 'colormath==2.0.2', 'pytest-cov', 'codecov'],
},
extras_require={"test": ["pytest", "colormath==2.0.2", "pytest-cov", "codecov"]},
entry_points="""
[rasterio.rio_plugins]
color=rio_color.scripts.cli:color
atmos=rio_color.scripts.cli:atmos
""")
""",
)

0 comments on commit a26526d

Please sign in to comment.