Skip to content
Snippets Groups Projects
Commit 4ddac894 authored by Orgis, Dr. Thomas's avatar Orgis, Dr. Thomas
Browse files

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.
parent 0264a0ea
Branches
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ index e4689f7..9068fdd 100644 ...@@ -35,7 +35,7 @@ index e4689f7..9068fdd 100644
endforeach(_comp ${_find_components}) endforeach(_comp ${_find_components})
endif(NOT CASACORE_INCLUDE_DIR) endif(NOT CASACORE_INCLUDE_DIR)
diff --git a/CMake/PythonInstall.cmake b/CMake/PythonInstall.cmake diff --git a/CMake/PythonInstall.cmake b/CMake/PythonInstall.cmake
index 173f995..c15bbab 100644 index 173f995..a1357c7 100644
--- a/CMake/PythonInstall.cmake --- a/CMake/PythonInstall.cmake
+++ b/CMake/PythonInstall.cmake +++ b/CMake/PythonInstall.cmake
@@ -24,10 +24,11 @@ @@ -24,10 +24,11 @@
...@@ -48,7 +48,7 @@ index 173f995..c15bbab 100644 ...@@ -48,7 +48,7 @@ index 173f995..c15bbab 100644
# Derive the Python site-packages installation directory and build directory. # Derive the Python site-packages installation directory and build directory.
-if(PYTHON_EXECUTABLE) -if(PYTHON_EXECUTABLE)
+if(Python_EXECUTABLE) +if(Python3_EXECUTABLE)
set(_cmd set(_cmd
"from distutils.sysconfig import get_python_lib" "from distutils.sysconfig import get_python_lib"
"from os.path import join" "from os.path import join"
...@@ -57,7 +57,7 @@ index 173f995..c15bbab 100644 ...@@ -57,7 +57,7 @@ index 173f995..c15bbab 100644
) )
execute_process( execute_process(
- COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}" - COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}"
+ COMMAND "${Python_EXECUTABLE}" "-c" "${_cmd}" + COMMAND "${Python3_EXECUTABLE}" "-c" "${_cmd}"
OUTPUT_VARIABLE _pydir OUTPUT_VARIABLE _pydir
ERROR_VARIABLE _pyerr ERROR_VARIABLE _pyerr
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
...@@ -66,7 +66,7 @@ index 173f995..c15bbab 100644 ...@@ -66,7 +66,7 @@ index 173f995..c15bbab 100644
message(STATUS "Installation directory for Python extensions: ${PYTHON_INSTALL_DIR}") message(STATUS "Installation directory for Python extensions: ${PYTHON_INSTALL_DIR}")
endif() endif()
-endif(PYTHON_EXECUTABLE) -endif(PYTHON_EXECUTABLE)
+endif(Python_EXECUTABLE) +endif(Python3_EXECUTABLE)
# #
...@@ -75,93 +75,57 @@ index 173f995..c15bbab 100644 ...@@ -75,93 +75,57 @@ index 173f995..c15bbab 100644
# Precondition check. # Precondition check.
- if(NOT PYTHON_EXECUTABLE) - if(NOT PYTHON_EXECUTABLE)
+ if(NOT Python_EXECUTABLE) + if(NOT Python3_EXECUTABLE)
message(FATAL_ERROR "python_install: Python interpreter not available") message(FATAL_ERROR "python_install: Python interpreter not available")
- endif(NOT PYTHON_EXECUTABLE) - endif(NOT PYTHON_EXECUTABLE)
+ endif(NOT Python_EXECUTABLE) + endif(NOT Python3_EXECUTABLE)
# Parse arguments. # Parse arguments.
# apart from the python files list, there are two additional arguments # apart from the python files list, there are two additional arguments
diff --git a/CMakeLists.txt b/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt
index 515aae1..671419d 100644 index 0ae97ae..73327a8 100644
--- a/CMakeLists.txt --- a/CMakeLists.txt
+++ b/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) find_package(CFITSIO REQUIRED)
-#Prevent accidentally finding old BoostConfig.cmake file from casapy -find_package(PythonLibs 3 REQUIRED)
+# An attempt at common logic for Python and Boost: -find_package(PythonInterp REQUIRED)
+# 0. Try CMake 3.12's FindPython, fall back to FindPythonInterp/Libs. -message(STATUS "Using python version ${PYTHON_VERSION_STRING}")
+# 1. Use a default Python being found (environment should provide that). +find_package(Python3 COMPONENTS Interpreter Development)
+# 2. Use that Python's version to look for modern versioned Boost pythonXY +message(STATUS "Using python version ${Python3_VERSION}")
+# component.
+# 3. If that fails, resort to unversioned Boost python. #Prevent accidentally finding old BoostConfig.cmake file from casapy
+# 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()
+
set(Boost_NO_BOOST_CMAKE ON) set(Boost_NO_BOOST_CMAKE ON)
-find_package(Boost COMPONENTS date_time filesystem python3 program_options system unit_test_framework REQUIRED) -set(BOOSTPY ${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
+set(boostcomp date_time filesystem program_options system unit_test_framework) +set(BOOSTPY ${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
+set(boostpy ${Python_VERSION_MAJOR}${Python_VERSION_MINOR}) find_package(Boost COMPONENTS date_time filesystem python${BOOSTPY} numpy${BOOSTPY} program_options system unit_test_framework REQUIRED)
+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()
+
include_directories(${Boost_INCLUDE_DIR}) include_directories(${Boost_INCLUDE_DIR})
+include_directories(${Python_INCLUDE_DIRS})
find_path(LOFAR_STATION_RESPONSE_DIR NAMES StationResponse/Station.h) @@ -198,7 +197,7 @@ set(EXTRA_LIBRARIES ${EXTRA_LIBRARIES}
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}
${CASACORE_LIBRARIES} ${CASACORE_LIBRARIES}
- ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PYTHON3_LIBRARY} ${Boost_LIBRARIES}
+ Boost::date_time Boost::filesystem Boost::system Boost::program_options Boost::python${boostpy}
${EXTRA_LIBRARIES} ${EXTRA_LIBRARIES}
- ${PYTHON_LIBRARIES} - ${PYTHON_LIBRARIES}
+ ${Python_LIBRARIES} + ${Python3_LIBRARIES}
${IDGAPI_LIBRARIES} ${IDGAPI_LIBRARIES}
Threads::Threads) Threads::Threads)
diff --git a/PythonDPPP/CMakeLists.txt b/PythonDPPP/CMakeLists.txt diff --git a/PythonDPPP/CMakeLists.txt b/PythonDPPP/CMakeLists.txt
index 9194dc7..c8284a8 100644 index 9194dc7..afd8545 100644
--- a/PythonDPPP/CMakeLists.txt --- a/PythonDPPP/CMakeLists.txt
+++ b/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, build this package. Otherwise give a warning.
-if(${Boost_PYTHON3_FOUND}) -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) include(PythonInstall)
@@ -25,15 +25,6 @@ if(${Boost_PYTHON3_FOUND}) @@ -25,16 +27,7 @@ if(${Boost_PYTHON3_FOUND})
# Install Python modules # Install Python modules
python_install(__init__.py DESTINATION lofar/pythondppp) python_install(__init__.py DESTINATION lofar/pythondppp)
...@@ -175,5 +139,8 @@ index 9194dc7..c8284a8 100644 ...@@ -175,5 +139,8 @@ index 9194dc7..c8284a8 100644
- include_directories(${Boost_INCLUDE_DIR}) - include_directories(${Boost_INCLUDE_DIR})
- -
# add_subdirectory(test) # add_subdirectory(test)
else() -else()
message (WARNING, " Boost-Python not found; PythonDPPP will not be built.") - message (WARNING, " Boost-Python not found; PythonDPPP will not be built.")
+#else()
+# message (WARNING, " Boost-Python not found; PythonDPPP will not be built.")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment