Skip to content

Commit

Permalink
Merging r367115, r367125, r367127, and r367153.
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
r367115 | jdevlieghere | 2019-07-26 16:26:33 +0200 (Fri, 26 Jul 2019) | 6 lines

[CMake] Loosen Python version check and ignore patch version

Some versions of macOS report a different patch version for the system
provided interpreter and libraries.

Differential revision: https://reviews.llvm.org/D65230
------------------------------------------------------------------------

------------------------------------------------------------------------
r367125 | jdevlieghere | 2019-07-26 18:15:19 +0200 (Fri, 26 Jul 2019) | 3 lines

[CMake] Print Python version on Windows

Trying to figure out what's causing the Windows bot to fail.
------------------------------------------------------------------------

------------------------------------------------------------------------
r367127 | jdevlieghere | 2019-07-26 18:32:49 +0200 (Fri, 26 Jul 2019) | 4 lines

[CMake] Fix find_python_libs_windows

Exporting PYTHON_INCLUDE_DIR to the Python scope somehow got lost in my
last change. Add it back again. This should fix the Windows bot!
------------------------------------------------------------------------

------------------------------------------------------------------------
r367153 | jdevlieghere | 2019-07-26 22:58:10 +0200 (Fri, 26 Jul 2019) | 5 lines

[CMake] Print the correct variables

This didn't get updated after we decided to set PYTHON_MAJOR_VERSION and
PYTHON_MINOR_VERSION in find_python_libs_windows, instead of parsing the
variables ourselves.
------------------------------------------------------------------------

llvm-svn: 369903
  • Loading branch information
zmodem committed Aug 26, 2019
1 parent 23c8505 commit 094e9b4
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions lldb/cmake/modules/LLDBConfig.cmake
Expand Up @@ -140,7 +140,6 @@ function(find_python_libs_windows)
PYTHONLIBS_VERSION_STRING "${python_version_str}")
message(STATUS "Found Python library version ${PYTHONLIBS_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+)[.]([0-9]+)[.][0-9]+" "python\\1\\2" PYTHONLIBS_BASE_NAME "${PYTHONLIBS_VERSION_STRING}")
set(PYTHONLIBS_VERSION_STRING "${PYTHONLIBS_VERSION_STRING}" PARENT_SCOPE)
unset(python_version_str)
else()
message(WARNING "Unable to find ${PYTHON_INCLUDE_DIR}/patchlevel.h, Python installation is corrupt.")
Expand Down Expand Up @@ -175,13 +174,32 @@ function(find_python_libs_windows)
return()
endif()

set (PYTHON_EXECUTABLE ${PYTHON_EXE} PARENT_SCOPE)
set (PYTHON_LIBRARY ${PYTHON_LIB} PARENT_SCOPE)
set (PYTHON_DLL ${PYTHON_DLL} PARENT_SCOPE)
set (PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR} PARENT_SCOPE)
# Find the version of the Python interpreter.
execute_process(COMMAND "${PYTHON_EXE}" -c
"import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))"
OUTPUT_VARIABLE PYTHON_VERSION_OUTPUT
RESULT_VARIABLE PYTHON_VERSION_RESULT
ERROR_QUIET)
if(NOT PYTHON_VERSION_RESULT)
string(REPLACE ";" "." PYTHON_VERSION_STRING "${PYTHON_VERSION_OUTPUT}")
list(GET PYTHON_VERSION_OUTPUT 0 PYTHON_VERSION_MAJOR)
list(GET PYTHON_VERSION_OUTPUT 1 PYTHON_VERSION_MINOR)
list(GET PYTHON_VERSION_OUTPUT 2 PYTHON_VERSION_PATCH)
endif()

message(STATUS "LLDB Found PythonExecutable: ${PYTHON_EXE}")
message(STATUS "LLDB Found PythonLibs: ${PYTHON_LIB}")
# Set the same variables as FindPythonInterp and FindPythonLibs.
set(PYTHON_EXECUTABLE ${PYTHON_EXE} PARENT_SCOPE)
set(PYTHON_LIBRARY ${PYTHON_LIB} PARENT_SCOPE)
set(PYTHON_DLL ${PYTHON_DLL} PARENT_SCOPE)
set(PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR} PARENT_SCOPE)
set(PYTHONLIBS_VERSION_STRING "${PYTHONLIBS_VERSION_STRING}" PARENT_SCOPE)
set(PYTHON_VERSION_STRING ${PYTHON_VERSION_STRING} PARENT_SCOPE)
set(PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR} PARENT_SCOPE)
set(PYTHON_VERSION_MINOR ${PYTHON_VERSION_MINOR} PARENT_SCOPE)
set(PYTHON_VERSION_PATCH ${PYTHON_VERSION_PATCH} PARENT_SCOPE)

message(STATUS "LLDB Found PythonExecutable: ${PYTHON_EXECUTABLE} (${PYTHON_VERSION_STRING})")
message(STATUS "LLDB Found PythonLibs: ${PYTHON_LIB} (${PYTHONLIBS_VERSION_STRING})")
message(STATUS "LLDB Found PythonDLL: ${PYTHON_DLL}")
message(STATUS "LLDB Found PythonIncludeDirs: ${PYTHON_INCLUDE_DIR}")
endfunction(find_python_libs_windows)
Expand All @@ -199,9 +217,18 @@ if (NOT LLDB_DISABLE_PYTHON)
find_package(PythonLibs REQUIRED)
endif()

if (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING AND
NOT CMAKE_CROSSCOMPILING)
message(FATAL_ERROR "Found incompatible Python interpreter (${PYTHON_VERSION_STRING}) and Python libraries (${PYTHONLIBS_VERSION_STRING})")
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 different 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)
Expand Down

0 comments on commit 094e9b4

Please sign in to comment.