Warning, /graphics/krita/cmake/modules/FindPythonLibrary.cmake is written in an unsupported language. File is not indexed.

0001 # Find Python
0002 # ~~~~~~~~~~~
0003 # Find the Python interpreter and related Python directories.
0004 #
0005 # This file defines the following variables:
0006 #
0007 # PYTHON_EXECUTABLE - The path and filename of the Python interpreter.
0008 #
0009 # PYTHON_SHORT_VERSION - The version of the Python interpreter found,
0010 #     excluding the patch version number. (e.g. 2.5 and not 2.5.1))
0011 #
0012 # PYTHON_LONG_VERSION - The version of the Python interpreter found as a human
0013 #     readable string.
0014 #
0015 # PYTHON_SITE_PACKAGES_DIR - Location of the Python site-packages directory.
0016 #
0017 # PYTHON_INCLUDE_PATH, PYTHON_INCLUDE_DIRS - Directory holding the python.h include file.
0018 #
0019 # PYTHON_LIBRARY, PYTHON_LIBRARIES- Location of the Python library.
0020 
0021 # SPDX-FileCopyrightText: 2007 Simon Edwards <simon@simonzone.com>
0022 # SPDX-FileCopyrightText: 2012 Luca Beltrame <lbeltrame@kde.org>
0023 #
0024 # SPDX-License-Identifier: BSD-3-Clause
0025 #
0026 
0027 if(APPLE)
0028     set(CMAKE_FRAMEWORK_PATH_OLD ${CMAKE_FRAMEWORK_PATH})
0029     set(CMAKE_FRAMEWORK_PATH "${CMAKE_INSTALL_PREFIX}/lib" ${CMAKE_SYSTEM_FRAMEWORK_PATH})
0030 endif(APPLE)
0031 
0032 include(FindPackageHandleStandardArgs)
0033 
0034 if (WIN32 OR APPLE)
0035     set(Python_FIND_STRATEGY LOCATION)
0036     find_package(Python 3.8 REQUIRED COMPONENTS Development Interpreter)
0037 else()
0038     find_package(Python 3.8 REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development)
0039 endif()
0040 
0041 message(STATUS "FindPythonLibrary: ${Python_Interpreter_FOUND}")
0042 
0043 if (Python_Interpreter_FOUND)
0044     set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
0045 
0046     # Set the Python libraries to what we actually found for interpreters
0047     set(Python_ADDITIONAL_VERSIONS "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
0048     # These are kept for compatibility
0049     set(PYTHON_SHORT_VERSION "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
0050     set(PYTHON_LONG_VERSION ${PYTHON_VERSION_STRING})
0051 
0052     if(Python_Development_FOUND)
0053         set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS})
0054         set(PYTHON_INCLUDE_PATH ${Python_INCLUDE_DIRS})
0055         set(PYTHON_LIBRARY ${Python_LIBRARIES})
0056     endif(Python_Development_FOUND)
0057 
0058     # Auto detect Python site-packages directory
0059     execute_process(COMMAND ${Python_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'))"
0060                     OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_DIR
0061                     OUTPUT_STRIP_TRAILING_WHITESPACE
0062                    )
0063 
0064     message(STATUS "Python system site-packages directory: ${PYTHON_SITE_PACKAGES_DIR}")
0065 
0066     unset(KRITA_PYTHONPATH_V4 CACHE)
0067     unset(KRITA_PYTHONPATH_V5 CACHE)
0068     set(_python_prefix_path ${CMAKE_PREFIX_PATH})
0069     if (WIN32)
0070         foreach(__p ${_python_prefix_path})
0071             set(KRITA_PYTHONPATH_V4 "${__p}/lib/krita-python-libs;${KRITA_PYTHONPATH_V4}")
0072             set(KRITA_PYTHONPATH_V5 "${__p}/Lib/site-packages;${KRITA_PYTHONPATH_V5}")
0073         endforeach()
0074     else()
0075         foreach(__p ${_python_prefix_path})
0076             set(KRITA_PYTHONPATH_V4 "${__p}/lib/krita-python-libs:${KRITA_PYTHONPATH_V4}")
0077             set(KRITA_PYTHONPATH_V5 "${__p}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages:${KRITA_PYTHONPATH_V5}")
0078         endforeach()
0079     endif()
0080 
0081     message(STATUS "Krita site-packages directories for SIP v4: ${KRITA_PYTHONPATH_V4}")
0082     message(STATUS "Krita site-packages directories for SIP v5+: ${KRITA_PYTHONPATH_V5}")
0083 endif()
0084 
0085 find_package_handle_standard_args(PythonLibrary DEFAULT_MSG PYTHON_LIBRARY PYTHON_INCLUDE_DIRS PYTHON_INCLUDE_PATH)
0086 
0087 if(APPLE)
0088     set(CMAKE_FRAMEWORK_PATH ${CMAKE_FRAMEWORK_PATH_OLD})
0089 endif(APPLE)