From 7ff3e6300f3adb64867b636c7638ee4e8b00ce5a Mon Sep 17 00:00:00 2001 From: yoni206 Date: Tue, 30 Mar 2021 17:11:10 -0700 Subject: [PATCH] Fix compilation of Python bindings for named build directories (#6244) In current master, the following fails whenever contains a /: ./configure.sh --python-bindings --name= The reason is that src/api/python/genkinds.py adds a directory to the python path while relying on the fact that the build directory is located directly under the main repo directory, which is not the case if contains a /. This PR fixes this by having cmake determine the right directory to add to the python path. --- src/api/python/CMakeLists.txt | 3 ++- src/api/python/{genkinds.py => genkinds.py.in} | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) rename src/api/python/{genkinds.py => genkinds.py.in} (92%) diff --git a/src/api/python/CMakeLists.txt b/src/api/python/CMakeLists.txt index b400c14e5..62482a0ba 100644 --- a/src/api/python/CMakeLists.txt +++ b/src/api/python/CMakeLists.txt @@ -26,12 +26,13 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories("${CMAKE_BINARY_DIR}/src/") # Generate cvc4kinds.{pxd,pyx} +configure_file(genkinds.py.in genkinds.py) add_custom_target( gen-pycvc4-kinds ALL COMMAND "${PYTHON_EXECUTABLE}" - "${CMAKE_CURRENT_LIST_DIR}/genkinds.py" + "${CMAKE_CURRENT_BINARY_DIR}/genkinds.py" --kinds-header "${PROJECT_SOURCE_DIR}/src/api/cvc4cppkind.h" --kinds-file-prefix "${CMAKE_CURRENT_BINARY_DIR}/cvc4kinds" DEPENDS diff --git a/src/api/python/genkinds.py b/src/api/python/genkinds.py.in similarity index 92% rename from src/api/python/genkinds.py rename to src/api/python/genkinds.py.in index 30ee18708..0f8ba4b45 100644 --- a/src/api/python/genkinds.py +++ b/src/api/python/genkinds.py.in @@ -25,11 +25,8 @@ import argparse import os import sys -# the following command in CVC4/build/src/api/python/CMakeFiles/gen-pycvc4-kinds.dir/build.make -# cd CVC4/build/src/api/python && /usr/bin/python3 CVC4/src/api/python/genkinds.py ... -# indicates we are in directory CVC4/build/src/api/python -# so we use ../../../../src/api to access CVC4/src/api/parsekinds.py -sys.path.insert(0, os.path.abspath('../../../../src/api')) +# get access to CVC4/src/api/parsekinds.py +sys.path.insert(0, os.path.abspath('${CMAKE_SOURCE_DIR}/src/api')) from parsekinds import * -- 2.30.2