Skip to content

Commit

Permalink
Revert "find_package(Python) (#1842)" (#1899)
Browse files Browse the repository at this point in the history
This reverts commit c87b61e, reversing
changes made to f25b198.
  • Loading branch information
casperdcl committed Aug 21, 2024
1 parent 084063b commit 9d7ebc4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 26 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

find_package(Git REQUIRED)
find_package(Python COMPONENTS Interpreter REQUIRED)

add_subdirectory(src/Core)
add_subdirectory(Wrappers/Python)
72 changes: 46 additions & 26 deletions Wrappers/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
find_package(Python COMPONENTS Interpreter REQUIRED)
option (BUILD_PYTHON_WRAPPER "Build Python Wrapper" ON)

if(PYTHON_DEST_DIR)
file(TO_CMAKE_PATH "${PYTHON_DEST_DIR}" PYTHON_DEST)
endif()
if (BUILD_PYTHON_WRAPPER)
find_package(PythonInterp REQUIRED)

message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
if(NOT DEFINED)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
#set(PYTHON_DEST_DIR "" CACHE PATH "Directory of the Python wrappers")
if (PYTHON_DEST_DIR)
file(TO_CMAKE_PATH "${PYTHON_DEST_DIR}" TMP)
set(PYTHON_DEST "${TMP}")
unset(TMP)
endif()

# TODO: add to add_custom_command DEPENDS the list of python files of the project.
# file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/cil/*.py )
message("SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL: $ENV{SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL}")
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
if(PYTHON_DEST_DIR)
message(STATUS "CIL install using ${Python_EXECUTABLE} -m pip install -t ${PYTHON_DEST}")
add_custom_target(pythonsetup ALL
COMMAND ${Python_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} -t ${PYTHON_DEST} --upgrade
DEPENDS cilacc)
else()
message(STATUS "CIL install using ${Python_EXECUTABLE} -m pip install")
add_custom_target(pythonsetup ALL
COMMAND ${Python_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} --upgrade
DEPENDS cilacc)
endif()
# install the data if not a conda build. With conda the data is in the dependency package cil-data
if (NOT CONDA_BUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cil)
message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
if(NOT DEFINED)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

find_package(PythonLibs)
if (PYTHONINTERP_FOUND)
message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
message(STATUS "Python version ${PYTHON_VERSION_STRING}")
endif()
if (PYTHONLIBS_FOUND)
message(STATUS "Found PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}")
message(STATUS "Found PYTHON_LIBRARIES=${PYTHON_LIBRARIES}")
endif()

if (PYTHONINTERP_FOUND)
message("Python found " ${PYTHON_EXECUTABLE})
# TODO: add to add_custom_command DEPENDS the list of python files of the project.
# file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/cil/*.py )
message("SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL: $ENV{SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL}")
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
if(PYTHON_DEST_DIR)
message(STATUS "CIL install using ${PYTHON_EXECUTABLE} -m pip install -t ${PYTHON_DEST}")
add_custom_target(pythonsetup ALL
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} -t ${PYTHON_DEST} --upgrade
DEPENDS cilacc)
else()
message(STATUS "CIL install using ${PYTHON_EXECUTABLE} -m pip install")
add_custom_target(pythonsetup ALL
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} --upgrade
DEPENDS cilacc)
endif()
# install the data if not a conda build. With conda the data is in the dependency package cil-data
if (NOT CONDA_BUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cil)
endif()
endif()
endif()

0 comments on commit 9d7ebc4

Please sign in to comment.