summaryrefslogtreecommitdiff
path: root/src/bindings/python/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/python/CMakeLists.txt')
-rw-r--r--src/bindings/python/CMakeLists.txt26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt
index 2c2c50126..44d64fb29 100644
--- a/src/bindings/python/CMakeLists.txt
+++ b/src/bindings/python/CMakeLists.txt
@@ -1,4 +1,10 @@
-find_package(PythonLibs REQUIRED)
+# Make sure that interpreter and libraries have a compatible version.
+# Note: We use the Python interpreter to determine the install path for Python
+# modules. If the interpreter and library have different version, the module
+# will be installed for the wrong Python version. Hence, we require the library
+# version to match the Python interpreter's version.
+find_package(PythonLibs
+ ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
set(SWIG_MODULE_CVC4_EXTRA_DEPS cvc4 cvc4parser)
@@ -17,3 +23,21 @@ else()
swig_add_library(CVC4 LANGUAGE Python SOURCES ${CVC4_SWIG_INTERFACE})
endif()
swig_link_libraries(CVC4 cvc4 cvc4parser ${PYTHON_LIBRARIES})
+
+
+# Install Python bindings to the corresponding python-*/site-packages
+# directory. Lookup Python module directory and store path in
+# PYTHON_MODULE_PATH.
+execute_process(COMMAND
+ ${PYTHON_EXECUTABLE} -c
+ "from distutils.sysconfig import get_python_lib;\
+ print(get_python_lib(plat_specific=True,\
+ prefix='${CMAKE_INSTALL_PREFIX}'))"
+ OUTPUT_VARIABLE PYTHON_MODULE_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Copy _CVC4.so and CVC4.py to PYTHON_MODULE_PATH
+install(TARGETS ${SWIG_MODULE_CVC4_REAL_NAME}
+ DESTINATION ${PYTHON_MODULE_PATH})
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CVC4.py
+ DESTINATION ${PYTHON_MODULE_PATH})
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback