From 4ddac8949a7a5256e20ce9734562a2aa107184bb Mon Sep 17 00:00:00 2001 From: "Dr. Thomas Orgis" <thomas.orgis@uni-hamburg.de> Date: Thu, 14 May 2020 14:02:12 +0200 Subject: [PATCH] DP3: update patch for proper requirement of Python 3 Can upstream be convinced to just use FindPython3? The other notable change in the patch is the removal of redundant Python searches in deeper level CMakeLists. Note: Build currently broken because of Casacore API, apparently. --- DP3-buildfix.patch | 97 +++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 65 deletions(-) diff --git a/DP3-buildfix.patch b/DP3-buildfix.patch index 290b428..2d7611c 100644 --- a/DP3-buildfix.patch +++ b/DP3-buildfix.patch @@ -35,7 +35,7 @@ index e4689f7..9068fdd 100644 endforeach(_comp ${_find_components}) endif(NOT CASACORE_INCLUDE_DIR) diff --git a/CMake/PythonInstall.cmake b/CMake/PythonInstall.cmake -index 173f995..c15bbab 100644 +index 173f995..a1357c7 100644 --- a/CMake/PythonInstall.cmake +++ b/CMake/PythonInstall.cmake @@ -24,10 +24,11 @@ @@ -48,7 +48,7 @@ index 173f995..c15bbab 100644 # Derive the Python site-packages installation directory and build directory. -if(PYTHON_EXECUTABLE) -+if(Python_EXECUTABLE) ++if(Python3_EXECUTABLE) set(_cmd "from distutils.sysconfig import get_python_lib" "from os.path import join" @@ -57,7 +57,7 @@ index 173f995..c15bbab 100644 ) execute_process( - COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}" -+ COMMAND "${Python_EXECUTABLE}" "-c" "${_cmd}" ++ COMMAND "${Python3_EXECUTABLE}" "-c" "${_cmd}" OUTPUT_VARIABLE _pydir ERROR_VARIABLE _pyerr OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -66,7 +66,7 @@ index 173f995..c15bbab 100644 message(STATUS "Installation directory for Python extensions: ${PYTHON_INSTALL_DIR}") endif() -endif(PYTHON_EXECUTABLE) -+endif(Python_EXECUTABLE) ++endif(Python3_EXECUTABLE) # @@ -75,93 +75,57 @@ index 173f995..c15bbab 100644 # Precondition check. - if(NOT PYTHON_EXECUTABLE) -+ if(NOT Python_EXECUTABLE) ++ if(NOT Python3_EXECUTABLE) message(FATAL_ERROR "python_install: Python interpreter not available") - endif(NOT PYTHON_EXECUTABLE) -+ endif(NOT Python_EXECUTABLE) ++ endif(NOT Python3_EXECUTABLE) # Parse arguments. # apart from the python files list, there are two additional arguments diff --git a/CMakeLists.txt b/CMakeLists.txt -index 515aae1..671419d 100644 +index 0ae97ae..73327a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -44,10 +44,40 @@ endif(IDGAPI_LIBRARIES AND IDGAPI_INCLUDE_DIRS) +@@ -44,13 +44,12 @@ endif(IDGAPI_LIBRARIES AND IDGAPI_INCLUDE_DIRS) find_package(CFITSIO REQUIRED) --#Prevent accidentally finding old BoostConfig.cmake file from casapy -+# An attempt at common logic for Python and Boost: -+# 0. Try CMake 3.12's FindPython, fall back to FindPythonInterp/Libs. -+# 1. Use a default Python being found (environment should provide that). -+# 2. Use that Python's version to look for modern versioned Boost pythonXY -+# component. -+# 3. If that fails, resort to unversioned Boost python. -+# Baseline for this is CMake 3.5, being available in LTS distros. -+# We could require Boost >= 1.67 and CMake >= 3.12 and get rid -+# of the fallbacks. -+ -+find_package(Python COMPONENTS Interpreter Development) -+if(NOT Python_FOUND) -+ message(STATUS "Falling back to deprecated Python search.") -+ find_package(PythonInterp REQUIRED) -+ find_package(PythonLibs REQUIRED) -+ set(Python_VERSION ${PYTHON_VERSION_STRING}) -+ set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) -+ set(Python_VERSION_MINOR ${PYTHON_VERSION_MINOR}) -+ set(Python_LIBRARIES ${PYTHON_LIBRARIES}) -+ set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) -+endif() -+ +-find_package(PythonLibs 3 REQUIRED) +-find_package(PythonInterp REQUIRED) +-message(STATUS "Using python version ${PYTHON_VERSION_STRING}") ++find_package(Python3 COMPONENTS Interpreter Development) ++message(STATUS "Using python version ${Python3_VERSION}") + + #Prevent accidentally finding old BoostConfig.cmake file from casapy set(Boost_NO_BOOST_CMAKE ON) --find_package(Boost COMPONENTS date_time filesystem python3 program_options system unit_test_framework REQUIRED) -+set(boostcomp date_time filesystem program_options system unit_test_framework) -+set(boostpy ${Python_VERSION_MAJOR}${Python_VERSION_MINOR}) -+find_package(Boost 1.67.0 COMPONENTS ${boostcomp} python${boostpy}) -+if(NOT Boost_FOUND) -+ message(STATUS "Falling back to old Boost search.") -+ set(boostpy "") -+ find_package(Boost REQUIRED COMPONENTS ${boostcomp} python${boostpy}) -+endif() -+ +-set(BOOSTPY ${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) ++set(BOOSTPY ${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) + find_package(Boost COMPONENTS date_time filesystem python${BOOSTPY} numpy${BOOSTPY} program_options system unit_test_framework REQUIRED) include_directories(${Boost_INCLUDE_DIR}) -+include_directories(${Python_INCLUDE_DIRS}) - find_path(LOFAR_STATION_RESPONSE_DIR NAMES StationResponse/Station.h) - find_library(LOFAR_STATION_RESPONSE_LIB stationresponse) -@@ -165,8 +195,6 @@ set(DPPP_OBJECT $<TARGET_OBJECTS:DPPP_OBJ>) - # - # Dependencies of AOFlagger - # --find_package(PythonLibs 3 REQUIRED) --find_package(PythonInterp REQUIRED) - find_package(LibXml2 REQUIRED) - find_package(PNG REQUIRED) - find_library(FFTW3_LIB fftw3 REQUIRED) -@@ -193,9 +221,9 @@ set(AOFLAGGERSTEP_OBJECT $<TARGET_OBJECTS:AOFlaggerStep_OBJ>) - set(EXTRA_LIBRARIES ${EXTRA_LIBRARIES} - ${AOFLAGGER_LIB} +@@ -198,7 +197,7 @@ set(EXTRA_LIBRARIES ${EXTRA_LIBRARIES} ${CASACORE_LIBRARIES} -- ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PYTHON3_LIBRARY} -+ Boost::date_time Boost::filesystem Boost::system Boost::program_options Boost::python${boostpy} + ${Boost_LIBRARIES} ${EXTRA_LIBRARIES} - ${PYTHON_LIBRARIES} -+ ${Python_LIBRARIES} ++ ${Python3_LIBRARIES} ${IDGAPI_LIBRARIES} Threads::Threads) diff --git a/PythonDPPP/CMakeLists.txt b/PythonDPPP/CMakeLists.txt -index 9194dc7..c8284a8 100644 +index 9194dc7..afd8545 100644 --- a/PythonDPPP/CMakeLists.txt +++ b/PythonDPPP/CMakeLists.txt -@@ -1,5 +1,5 @@ +@@ -1,5 +1,7 @@ # If Boost-Python3 found, build this package. Otherwise give a warning. -if(${Boost_PYTHON3_FOUND}) -+if(${Boost_PYTHON${boostpy}_FOUND}) ++#if(${Boost_PYTHON${boostpy}_FOUND}) ++# We set Boost-python as reuired in toplevel build file. ++if(TRUE) include(PythonInstall) -@@ -25,15 +25,6 @@ if(${Boost_PYTHON3_FOUND}) +@@ -25,16 +27,7 @@ if(${Boost_PYTHON3_FOUND}) # Install Python modules python_install(__init__.py DESTINATION lofar/pythondppp) @@ -175,5 +139,8 @@ index 9194dc7..c8284a8 100644 - include_directories(${Boost_INCLUDE_DIR}) - # add_subdirectory(test) - else() - message (WARNING, " Boost-Python not found; PythonDPPP will not be built.") +-else() +- message (WARNING, " Boost-Python not found; PythonDPPP will not be built.") ++#else() ++# message (WARNING, " Boost-Python not found; PythonDPPP will not be built.") + endif() -- GitLab