Skip to content

Commit

Permalink
Reactivate Pypy support, except -r/--reference due to missing GDAL/OG…
Browse files Browse the repository at this point in the history
…R bindings.
  • Loading branch information
alexamici committed Apr 3, 2016
1 parent a6bff53 commit ed2b93a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ language: python
python: 3.5
env:
- TOX_ENV=quality-check
- TOX_ENV=pypy
- TOX_ENV=py35
- TOX_ENV=py34
- TOX_ENV=py33
Expand Down
31 changes: 18 additions & 13 deletions elevation/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import functools

import click
import rasterio
import fiona


import elevation
from . import util
Expand Down Expand Up @@ -72,15 +69,23 @@ def seed(**kwargs):
elevation.seed(**kwargs)


def parse_bounds(reference):
# ASSUMPTION: rasterio and fiona bounds are given in geodetic WGS84 crs
try:
with rasterio.open(reference) as datasource:
pass
except:
with fiona.open(reference) as datasource:
pass
return datasource.bounds
try:
# NOTE: GDAL/OGR bindings are not supported on Pypy
import rasterio
import fiona

def import_bounds(reference):
# ASSUMPTION: rasterio and fiona bounds are given in geodetic WGS84 crs
try:
with rasterio.open(reference) as datasource:
bounds = datasource.bounds
except:
with fiona.open(reference) as datasource:
bounds = datasource.bounds
return bounds
except ImportError:
def import_bounds(reference):
raise click.BadOptionUsage("-r/--reference disabled, to enable it install rasterio and fiona.")


def ensure_bounds(wrapped):
Expand All @@ -90,7 +95,7 @@ def wrapper(bounds, reference, **kwargs):
if not reference:
raise ValueError("bounds are not defined.")
else:
bounds = parse_bounds(reference)
bounds = import_bounds(reference)
return wrapped(bounds=bounds, **kwargs)
return wrapper

Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def read(fname):
'appdirs',
'fasteners',
'click',
'rasterio',
'fiona',
],
extras_require={
'reference': ['rasterio', 'fiona'],
},
zip_safe=True,
classifiers=[
'Development Status :: 4 - Beta',
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = docs, py27, py33, py34, py35, quality-check
envlist = docs, py27, py33, py34, py35, pypy, quality-check

# rasterio install crashes if numpy is not already installed see bopen/elevation#17

Expand All @@ -9,6 +9,10 @@ deps =
-r{toxinidir}/requirements-tests.txt
commands = py.test {posargs:tests}

[testenv:pypy]
deps = -r{toxinidir}/requirements-tests.txt
commands = py.test {posargs:tests}

[testenv:docs]
deps =
-r{toxinidir}/requirements-setup.txt
Expand Down

0 comments on commit ed2b93a

Please sign in to comment.