| 1 |
############################################################################### |
| 2 |
# Top contributors (to current version): |
| 3 |
# Daniel Larraz, Yoni Zohar, Andrew Reynolds |
| 4 |
# |
| 5 |
# This file is part of the cvc5 project. |
| 6 |
# |
| 7 |
# Copyright (c) 2009-2025 by the authors listed in the file AUTHORS |
| 8 |
# in the top-level source directory and their institutional affiliations. |
| 9 |
# All rights reserved. See the file COPYING in the top-level source |
| 10 |
# directory for licensing information. |
| 11 |
# ############################################################################# |
| 12 |
# |
| 13 |
# The build system configuration. |
| 14 |
## |
| 15 |
|
| 16 |
add_custom_target(build-pyapitests) |
| 17 |
add_dependencies(build-apitests build-pyapitests) |
| 18 |
|
| 19 |
add_custom_target(pyapitests |
| 20 |
COMMAND ctest --output-on-failure -L "pyapi" -j${CTEST_NTHREADS} $$ARGS |
| 21 |
DEPENDS build-pyapitests) |
| 22 |
|
| 23 |
if(WIN32) |
| 24 |
set(CVC5_PYAPI_TEST_DIR ${CMAKE_BINARY_DIR}/cvc5-pyapi-test) |
| 25 |
|
| 26 |
set(WHEEL_INSTALL_CMD |
| 27 |
"${Python_EXECUTABLE} -m pip install --prefix ${CVC5_PYAPI_TEST_DIR}") |
| 28 |
|
| 29 |
# Install the cvc5 Python bindings in the build directory to run tests. |
| 30 |
# On Windows, adding the directory with the Python bindings to PYTHONPATH |
| 31 |
# is not enough because Python only searches for DLL dependencies for |
| 32 |
# extension modules in system paths and the directory containing the PYD file. |
| 33 |
# Specifically, since Python 3.8, PATH and the current working directory are |
| 34 |
# no longer used for this purpose. See: |
| 35 |
# https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew |
| 36 |
add_custom_command( |
| 37 |
OUTPUT ${CVC5_PYAPI_TEST_DIR} |
| 38 |
COMMAND |
| 39 |
${CMAKE_COMMAND} |
| 40 |
-DPython_EXECUTABLE=${Python_EXECUTABLE} |
| 41 |
-DRepairwheel_EXECUTABLE=${Repairwheel_EXECUTABLE} |
| 42 |
-DBUILD_DIR=${CMAKE_BINARY_DIR} |
| 43 |
-DDEPS_BASE=${DEPS_BASE} |
| 44 |
-DINSTALL_CMD="${WHEEL_INSTALL_CMD}" |
| 45 |
-P ${CMAKE_SOURCE_DIR}/cmake/install_python_wheel.cmake |
| 46 |
DEPENDS cvc5_python_api |
| 47 |
) |
| 48 |
|
| 49 |
add_custom_target(setup-cvc5-pyapi DEPENDS ${CVC5_PYAPI_TEST_DIR}) |
| 50 |
|
| 51 |
add_dependencies(build-pyapitests setup-cvc5-pyapi) |
| 52 |
|
| 53 |
# Get path to the python bindings installed in the build directory |
| 54 |
execute_process(COMMAND |
| 55 |
${Python_EXECUTABLE} -c |
| 56 |
"import os.path;import sysconfig;\ |
| 57 |
print('${CVC5_PYAPI_TEST_DIR}'+\ |
| 58 |
sysconfig.get_paths()['platlib'].split(sysconfig.get_config_var('platbase'))[1])" |
| 59 |
OUTPUT_VARIABLE PYTHON_MODULE_PATH |
| 60 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 61 |
else() |
| 62 |
set(PYTHON_MODULE_PATH ${CMAKE_BINARY_DIR}/src/api/python) |
| 63 |
add_dependencies(build-pyapitests cvc5_python_api) |
| 64 |
endif() |
| 65 |
|
| 66 |
# Add Python bindings API tests. |
| 67 |
macro(cvc5_add_python_api_test name dir) |
| 68 |
set(pyname pyapi_${name}) |
| 69 |
if("${dir}" STREQUAL "") |
| 70 |
set(test_name api/python/${pyname}) |
| 71 |
else() |
| 72 |
set(test_name api/python/${dir}/${pyname}) |
| 73 |
endif() |
| 74 |
add_test (NAME ${test_name} |
| 75 |
COMMAND ${Python_EXECUTABLE} |
| 76 |
${CMAKE_CURRENT_SOURCE_DIR}/${name}.py) |
| 77 |
# directory for importing the python bindings |
| 78 |
set_tests_properties(${test_name} |
| 79 |
PROPERTIES LABELS "api pyapi" |
| 80 |
ENVIRONMENT PYTHONPATH=${PYTHON_MODULE_PATH}) |
| 81 |
endmacro() |
| 82 |
|
| 83 |
# add specific test files |
| 84 |
cvc5_add_python_api_test(boilerplate "") |
| 85 |
cvc5_add_python_api_test(ouroborous "") |
| 86 |
cvc5_add_python_api_test(reset_assertions "") |
| 87 |
cvc5_add_python_api_test(smt2_compliance "") |
| 88 |
cvc5_add_python_api_test(two_solvers "") |
| 89 |
|
| 90 |
if (NOT ENABLE_SAFE_MODE AND NOT ENABLE_STABLE_MODE) |
| 91 |
cvc5_add_python_api_test(sep_log_api "") |
| 92 |
endif() |
| 93 |
|
| 94 |
add_subdirectory(issues) |