ECC-204 Python: remove support for deprecated array handler

This commit is contained in:
Florian Rathgeber 2016-07-13 17:48:20 +01:00
parent cc54d6810a
commit 95455c34a0
2 changed files with 14 additions and 26 deletions

View File

@ -5,9 +5,6 @@ if( HAVE_PYTHON )
# include( ${SWIG_USE_FILE} )
#endif()
# check for Numpy
find_package( NumPy )
###############################################################################
# swig python interface
@ -15,13 +12,6 @@ if( HAVE_PYTHON )
if( PYTHONLIBS_FOUND )
# preparing for generating setup.py -- this may not be needed as cmake can do the swig + shared libs without libtool
if( NUMPY_FOUND )
set( DATA_HANDLER "numpy" )
else()
set( DATA_HANDLER "array" )
endif()
set( _swig_c_wrapper swig_wrap_${DATA_HANDLER}.c )
set( _swig_py_wrapper swig_wrap_${DATA_HANDLER}.py )
if( HAVE_LIBJASPER )
get_filename_component(JASPER_DIR ${JASPER_INCLUDE_DIR} PATH )
@ -49,13 +39,13 @@ if( HAVE_PYTHON )
# Build the extension module for use in build tree with RPATH pointing to the build tree
add_custom_command( OUTPUT ${_gribapi_swig}
COMMAND ${PYTHON_EXECUTABLE} setup.py build_ext --inplace -R ${CMAKE_BINARY_DIR}/lib
DEPENDS grib_interface.h grib_interface.c ${_swig_c_wrapper} setup.py.in eccodes )
DEPENDS grib_interface.h grib_interface.c swig_wrap_numpy.c setup.py.in eccodes )
add_custom_target(build_swig_wrapper ALL DEPENDS ${_gribapi_swig})
#ecbuild_add_library(TARGET _gribapi_swig
# TYPE SHARED
# NOINSTALL
# SOURCES grib_interface.h grib_interface.c ${_swig_c_wrapper}
# SOURCES grib_interface.h grib_interface.c swig_wrap_numpy.c
# INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PYTHON_INCLUDE_DIRS}
# LIBS eccodes ${PYTHON_LIBRARIES} )
# Don't use the lib prefix. This is needed for the python case where a _modulename.so is generated
@ -63,7 +53,7 @@ if( HAVE_PYTHON )
# Copy gribapi and eccodes python modules to build area
file( COPY eccodes gribapi DESTINATION . )
configure_file( ${_swig_py_wrapper} gribapi/gribapi_swig.py COPYONLY )
configure_file( swig_wrap_numpy.py gribapi/gribapi_swig.py COPYONLY )
# Call distutils for installation
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install --prefix ${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")

View File

@ -4,11 +4,20 @@ from distutils.core import setup, Extension
import os
import sys
attdict = dict(sources=['@CMAKE_CURRENT_SOURCE_DIR@/@_swig_c_wrapper@',
import numpy
# Obtain the numpy include directory. This logic works across numpy versions.
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
attdict = dict(sources=['@CMAKE_CURRENT_SOURCE_DIR@/swig_wrap_numpy.c',
'@CMAKE_CURRENT_SOURCE_DIR@/grib_interface.c'],
swig_opts=[],
include_dirs=['.', '@CMAKE_CURRENT_BINARY_DIR@/../src',
'@CMAKE_CURRENT_SOURCE_DIR@/../src'],
'@CMAKE_CURRENT_SOURCE_DIR@/../src',
numpy_include],
library_dirs=['@CMAKE_BINARY_DIR@/lib'],
libraries=['eccodes'],
extra_objects=[],
@ -51,17 +60,6 @@ if with_aec:
add_attribute(libraries='aec')
data_handler = '@DATA_HANDLER@'
if data_handler == "numpy":
import numpy
# Obtain the numpy include directory. This logic works across numpy versions.
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
add_attribute(include_dirs=numpy_include)
setup(name='eccodes',
version='@ECCODES_VERSION_STR@',
author='ECMWF',