ECC-154: Install python module correctly

This commit is contained in:
Shahram Najm 2015-10-27 16:28:10 +00:00
parent f431b22d6c
commit d174d6a24b
3 changed files with 14 additions and 6 deletions

View File

@ -14,9 +14,10 @@ if( HAVE_PYTHON )
#if( SWIG_FOUND AND PYTHONLIBS_FOUND )
if( PYTHONLIBS_FOUND )
set(PYTHON_DEST "${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/eccodes" )
set(PYTHON_DEST_ECCODES "${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/eccodes" )
set(PYTHON_DEST_GRIBAPI "${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/gribapi" )
file( RELATIVE_PATH relative_rpath "${CMAKE_INSTALL_PREFIX}/${PYTHON_DEST}" "${${PNAME}_FULL_INSTALL_LIB_DIR}" )
file( RELATIVE_PATH relative_rpath "${CMAKE_INSTALL_PREFIX}/${PYTHON_DEST_ECCODES}" "${${PNAME}_FULL_INSTALL_LIB_DIR}" )
# debug_var( relative_rpath )
@ -87,11 +88,14 @@ if( HAVE_PYTHON )
add_custom_target(copy_swig_py ALL DEPENDS ${_swig_py})
#######################
install(TARGETS _gribapi_swig DESTINATION ${PYTHON_DEST} )
install(TARGETS _gribapi_swig DESTINATION ${PYTHON_DEST_GRIBAPI} )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gribapi_swig.py DESTINATION ${PYTHON_DEST})
install(FILES gribapi.py DESTINATION ${PYTHON_DEST})
install(FILES eccodes.py DESTINATION ${PYTHON_DEST})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gribapi_swig.py DESTINATION ${PYTHON_DEST_GRIBAPI})
install(FILES gribapi.py DESTINATION ${PYTHON_DEST_GRIBAPI})
install(FILES eccodes.py DESTINATION ${PYTHON_DEST_ECCODES})
install(FILES init_gribapi.py DESTINATION ${PYTHON_DEST_GRIBAPI} RENAME __init__.py)
install(FILES init_eccodes.py DESTINATION ${PYTHON_DEST_ECCODES} RENAME __init__.py)
endif()

2
python/init_eccodes.py Normal file
View File

@ -0,0 +1,2 @@
from .eccodes import *
from .eccodes import __version__

2
python/init_gribapi.py Normal file
View File

@ -0,0 +1,2 @@
from .gribapi import * # noqa
from .gribapi import __version__