Pull in rio-insp changes from master.

This commit is contained in:
Kevin Wurster 2015-06-03 16:59:02 -04:00
commit 90f8d842a4
3 changed files with 18 additions and 16 deletions

View File

@ -223,10 +223,8 @@ def info(ctx, input, aspect, indent, namespace, meta_member, verbose, bidx,
# Insp command.
@click.command(short_help="Open a data file and start an interpreter.")
@options.file_in_arg
@click.option(
'--ipython/--no-ipython',
default=True,
help='Use IPython as interpreter (default: True).')
@click.option('--ipython', 'interpreter', flag_value='ipython',
help="Use IPython as interpreter.")
@click.option(
'-m',
'--mode',
@ -234,7 +232,7 @@ def info(ctx, input, aspect, indent, namespace, meta_member, verbose, bidx,
default='r',
help="File mode (default 'r').")
@click.pass_context
def insp(ctx, input, mode, ipython):
def insp(ctx, input, mode, interpreter):
""" Open the input file in a Python interpreter.
IPython will be used as the default interpreter, if available.
@ -251,7 +249,7 @@ def insp(ctx, input, mode, ipython):
'for more information.' % (
rasterio.__version__,
'.'.join(map(str, sys.version_info[:3]))),
src, ipython)
src, interpreter)
except Exception:
logger.exception("Exception caught during processing")
raise click.Abort()

View File

@ -48,18 +48,16 @@ def stats(source):
return Stats(numpy.min(arr), numpy.max(arr), numpy.mean(arr))
def main(banner, dataset, ipython):
def main(banner, dataset, alt_interpreter=None):
""" Main entry point for use with python interpreter """
try:
import IPython
except ImportError:
ipython = False
local = dict(funcs, src=dataset, np=numpy, rio=rasterio, plt=plt)
if ipython:
if not alt_interpreter:
code.interact(banner, local=local)
elif alt_interpreter == 'ipython':
import IPython
IPython.InteractiveShell.banner1 = banner
IPython.start_ipython(argv=[], user_ns=local)
else:
code.interact(banner, local=local)
raise ValueError("Unsupported interpreter '%s'" % alt_interpreter)
return 0

View File

@ -125,12 +125,16 @@ if os.environ.get('PACKAGE_DATA'):
copy_data_tree(projdatadir, 'rasterio/proj_data')
ext_options = dict(
extra_compile_args=['-Wno-unused-parameter', '-Wno-unused-function'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_link_args=extra_link_args)
if not os.name == "nt":
# These options fail on Windows if using Visual Studio
ext_options['extra_compile_args'] = ['-Wno-unused-parameter',
'-Wno-unused-function']
log.debug('ext_options:\n%s', pprint.pformat(ext_options))
# When building from a repo, Cython is required.
@ -245,7 +249,9 @@ setup_args = dict(
include_package_data=True,
ext_modules=ext_modules,
zip_safe=False,
install_requires=inst_reqs)
install_requires=inst_reqs,
extras_require={
'ipython': ['ipython>=2.0']})
if os.environ.get('PACKAGE_DATA'):
setup_args['package_data'] = {'rasterio': ['gdal_data/*', 'proj_data/*']}