Skip to content

Commit

Permalink
CMake: update path to install python binding
Browse files Browse the repository at this point in the history
Install python libs with python interface.
Fix #20
  • Loading branch information
Clement Champetier committed Jul 20, 2015
1 parent acdcde7 commit 3b91c66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ script:

# tests
- cd ${TRAVIS_BUILD_DIR}
- export PYTHONPATH=$PYTHONPATH:`pwd`/install/lib/python/site-packages
- export PYTHONPATH=$PYTHONPATH:`pwd`/install/lib/python2.7/site-packages
- nosetests pyTest
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,23 @@ if(SWIG_FOUND)
endif()
swig_link_libraries(sequenceparser-py sequenceparser-shared ${PYTHON_LIBRARIES})

# Get path to install python binding
if(PYTHONLIBS_VERSION_STRING) # CMake >=2.8.11
string(SUBSTRING ${PYTHONLIBS_VERSION_STRING} 0 3 PYTHON_VERSION)
else()
set(PYTHON_VERSION ${SEQUENCEPARSER_PYTHON_VERSION})
endif()
set(SEQUENCEPARSER_PYTHON_MODULE_OUTPUT_DIR "lib/python${PYTHON_VERSION}/site-packages/pySequenceParser/")

# Install python interface
set(SEQUENCEPARSER_PYTHON_BINDING_FILE "${CMAKE_SWIG_OUTDIR}/sequenceParser.py")
set(SEQUENCEPARSER_PYTHON_MODULE_OUTPUT_DIR "lib/python${PYTHONLIBS_VERSION_STRING}/site-packages/pySequenceParser/")
install(
FILES ${SEQUENCEPARSER_PYTHON_BINDING_FILE} ${SEQUENCEPARSER_PYTHON_INIT_FILE}
DESTINATION ${SEQUENCEPARSER_PYTHON_MODULE_OUTPUT_DIR}
OPTIONAL
)
# Install python lib and __init__.py files
install(TARGETS ${SWIG_MODULE_sequenceparser-py_REAL_NAME} DESTINATION "lib/python${PYTHONLIBS_VERSION_STRING}/site-packages/pySequenceParser/" OPTIONAL)
install(TARGETS ${SWIG_MODULE_sequenceparser-py_REAL_NAME} DESTINATION "${SEQUENCEPARSER_PYTHON_MODULE_OUTPUT_DIR}" OPTIONAL)
install(CODE "file(WRITE ${CMAKE_INSTALL_PREFIX}/${SEQUENCEPARSER_PYTHON_MODULE_OUTPUT_DIR}/__init__.py)")
else()
message("PYTHON not found, will not build python binding.")
Expand Down

0 comments on commit 3b91c66

Please sign in to comment.