Should be fixed by 8c8ffd461d16681cb1fc764bedfa8b09fde260aa
On Mon, Jan 6, 2020 at 10:17 AM Davidino Italiano <ditali...@apple.com> wrote: > > > > > On Jan 6, 2020, at 9:07 AM, Jonas Devlieghere via lldb-commits > > <lldb-commits@lists.llvm.org> wrote: > > > > > > Author: Jonas Devlieghere > > Date: 2020-01-06T09:05:05-08:00 > > New Revision: b3757f3091d1c718a91f5b06b7364b2af28339fa > > > > URL: > > https://github.com/llvm/llvm-project/commit/b3757f3091d1c718a91f5b06b7364b2af28339fa > > DIFF: > > https://github.com/llvm/llvm-project/commit/b3757f3091d1c718a91f5b06b7364b2af28339fa.diff > > > > LOG: [lldb/CMake] Autodetect Python dependency > > > > Python was the last remaining "optional" dependency for LLDB. This moves > > the code to find Python into FindPythonInterpAndLibs using the same > > principles as FindCursesAndPanel. > > > > Differential revision: https://reviews.llvm.org/D72107 > > > > Added: > > lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > > > Modified: > > lldb/cmake/modules/LLDBConfig.cmake > > > > Removed: > > > > > > > > ################################################################################ > > diff --git a/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > b/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > new file mode 100644 > > index 000000000000..fcbf0212d72b > > --- /dev/null > > +++ b/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > @@ -0,0 +1,51 @@ > > +#.rst: > > +# FindPythonInterpAndLibs > > +# ----------- > > +# > > +# Find the python interpreter and libraries as a whole. > > + > > +if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE) > > + set(PYTHONINTERPANDLIBS_FOUND TRUE) > > +else() > > + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") > > + find_package(Python3 COMPONENTS Interpreter Development QUIET) > > + if (Python3_FOUND AND Python3_Interpreter_FOUND) > > + set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) > > + set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS}) > > + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) > > + mark_as_advanced( > > + PYTHON_LIBRARIES > > + PYTHON_INCLUDE_DIRS > > + PYTHON_EXECUTABLE) > > + endif() > > + else() > > + find_package(PythonInterp QUIET) > > + find_package(PythonLibs QUIET) > > + if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND) > > + if (NOT CMAKE_CROSSCOMPILING) > > + string(REPLACE "." ";" pythonlibs_version_list > > ${PYTHONLIBS_VERSION_STRING}) > > + list(GET pythonlibs_version_list 0 pythonlibs_major) > > + list(GET pythonlibs_version_list 1 pythonlibs_minor) > > + > > + # Ignore the patch version. Some versions of macOS report a > > diff erent > > + # patch version for the system provided interpreter and libraries. > > + if (CMAKE_CROSSCOMPILING OR (PYTHON_VERSION_MAJOR VERSION_EQUAL > > pythonlibs_major AND > > + PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor)) > > + mark_as_advanced( > > + PYTHON_LIBRARIES > > + PYTHON_INCLUDE_DIRS > > + PYTHON_EXECUTABLE) > > + endif() > > + endif() > > + endif() > > + endif() > > + > > + include(FindPackageHandleStandardArgs) > > + find_package_handle_standard_args(PythonInterpAndLibs > > + FOUND_VAR > > + PYTHONINTERPANDLIBS_FOUND > > + REQUIRED_VARS > > + PYTHON_LIBRARIES > > + PYTHON_INCLUDE_DIRS > > + PYTHON_EXECUTABLE) > > +endif() > > > > diff --git a/lldb/cmake/modules/LLDBConfig.cmake > > b/lldb/cmake/modules/LLDBConfig.cmake > > index 52b8257951be..12fb97fc9d7d 100644 > > --- a/lldb/cmake/modules/LLDBConfig.cmake > > +++ b/lldb/cmake/modules/LLDBConfig.cmake > > @@ -51,16 +51,8 @@ add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable > > editline support in LLDB" Li > > add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" > > CursesAndPanel CURSESANDPANEL_FOUND) > > add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support > > in LLDB" LibLZMA LIBLZMA_FOUND) > > add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in > > LLDB" Lua LUA_FOUND) > > +add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting > > support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND) > > > > -set(default_enable_python ON) > > - > > -if(CMAKE_SYSTEM_NAME MATCHES "Android") > > - set(default_enable_python OFF) > > -elseif(IOS) > > - set(default_enable_python OFF) > > -endif() > > - > > -option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." > > ${default_enable_python}) > > option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to > > locate Python." OFF) > > option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not > > install a copy of it" OFF) > > option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if > > available" ON) > > @@ -142,48 +134,13 @@ if (LLDB_ENABLE_LIBEDIT) > > endif() > > > > if (LLDB_ENABLE_PYTHON) > > - if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") > > - find_package(Python3 COMPONENTS Interpreter Development REQUIRED) > > - if(Python3_VERSION VERSION_LESS 3.5) > > - message(SEND_ERROR "Python 3.5 or newer is required (found: > > ${Python3_VERSION}") > > - endif() > > - set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) > > - include_directories(${Python3_INCLUDE_DIRS}) > > - > > - if (NOT LLDB_RELOCATABLE_PYTHON) > > - get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY) > > - file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME) > > - endif() > > - else() > > - find_package(PythonInterp REQUIRED) > > - find_package(PythonLibs REQUIRED) > > - > > - if (NOT CMAKE_CROSSCOMPILING) > > - string(REPLACE "." ";" pythonlibs_version_list > > ${PYTHONLIBS_VERSION_STRING}) > > - list(GET pythonlibs_version_list 0 pythonlibs_major) > > - list(GET pythonlibs_version_list 1 pythonlibs_minor) > > - > > - # Ignore the patch version. Some versions of macOS report a > > diff erent patch > > - # version for the system provided interpreter and libraries. > > - if (NOT PYTHON_VERSION_MAJOR VERSION_EQUAL pythonlibs_major OR > > - NOT PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor) > > - message(FATAL_ERROR "Found incompatible Python interpreter > > (${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})" > > - " and Python libraries > > (${pythonlibs_major}.${pythonlibs_minor})") > > - endif() > > - endif() > > - > > - if (PYTHON_INCLUDE_DIR) > > - include_directories(${PYTHON_INCLUDE_DIR}) > > - endif() > > + include_directories(${PYTHON_INCLUDE_DIRS}) > > + if (NOT LLDB_RELOCATABLE_PYTHON) > > + get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY) > > + file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME) > > endif() > > endif() > > > > -if (NOT LLDB_ENABLE_PYTHON) > > - unset(PYTHON_INCLUDE_DIR) > > - unset(PYTHON_LIBRARIES) > > - unset(PYTHON_EXECUTABLE) > > -endif() > > - > > if (LLVM_EXTERNAL_CLANG_SOURCE_DIR) > > include_directories(${LLVM_EXTERNAL_CLANG_SOURCE_DIR}/include) > > else () > > > > diff --git a/lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > b/lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > new file mode 100644 > > index 000000000000..90c902f74ae5 > > --- /dev/null > > +++ b/lldb/lldb/cmake/modules/FindPythonInterpAndLibs.cmake > > @@ -0,0 +1,51 @@ > > +#.rst: > > +# FindPythonInterpndLibs > > +# ----------- > > +# > > +# Find the python interpreter and libraries as a whole. > > + > > +if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS AND PYTHON_EXECUTABLE) > > + set(PYTHONINTERPANDLIBS_FOUND TRUE) > > +else() > > + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") > > + find_package(Python3 COMPONENTS Interpreter Development QUIET) > > + if (Python3_FOUND AND Python3_Interpreter_FOUND) > > + set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) > > + set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS}) > > + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) > > + mark_as_advanced( > > + PYTHON_LIBRARIES > > + PYTHON_INCLUDE_DIRS > > + PYTHON_EXECUTABLE) > > + endif() > > + else() > > + find_package(PythonInterp QUIET) > > + find_package(PythonLibs QUIET) > > + if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND) > > + if (NOT CMAKE_CROSSCOMPILING) > > + string(REPLACE "." ";" pythonlibs_version_list > > ${PYTHONLIBS_VERSION_STRING}) > > + list(GET pythonlibs_version_list 0 pythonlibs_major) > > + list(GET pythonlibs_version_list 1 pythonlibs_minor) > > + > > + # Ignore the patch version. Some versions of macOS report a > > diff erent > > + # patch version for the system provided interpreter and libraries. > > + if (CMAKE_CROSSCOMPILING OR (PYTHON_VERSION_MAJOR VERSION_EQUAL > > pythonlibs_major AND > > + PYTHON_VERSION_MINOR VERSION_EQUAL pythonlibs_minor)) > > + mark_as_advanced( > > + PYTHON_LIBRARIES > > + PYTHON_INCLUDE_DIRS > > + PYTHON_EXECUTABLE) > > + endif() > > + endif() > > + endif() > > + endif() > > +c > > + include(FindPackageHandleStandardArgs) > > + find_package_handle_standard_args(PythonInterpAndLibs > > + FOUND_VAR > > + PYTHONINTERPANDLIBS_FOUND > > + REQUIRED_VARS > > + PYTHON_LIBRARIES > > + PYTHON_INCLUDE_DIRS > > + PYTHON_EXECUTABLE) > > +endif() > > > > > I see a bunch of tests failing after this: "ImportError: No module named > site". > Reverting seems to fix the problem. If you need any info to reproduce let me > know. > > -- > Davide _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits