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 (ENABLE_PYTHON_2)
0035     find_package(Python 2.7 REQUIRED COMPONENTS Development Interpreter)
0036 else(ENABLE_PYTHON_2)
0037     if (MINGW OR APPLE)
0038         find_package(Python 3.8 REQUIRED COMPONENTS Development Interpreter)
0039     else()
0040         find_package(Python 3.0 REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development)
0041     endif()
0042 endif(ENABLE_PYTHON_2)
0043 
0044 message(STATUS "FindPythonLibrary: ${Python_Interpreter_FOUND}")
0045 
0046 if (Python_Interpreter_FOUND)
0047     set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
0048 
0049     # Set the Python libraries to what we actually found for interpreters
0050     set(Python_ADDITIONAL_VERSIONS "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
0051     # These are kept for compatibility
0052     set(PYTHON_SHORT_VERSION "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
0053     set(PYTHON_LONG_VERSION ${PYTHON_VERSION_STRING})
0054 
0055     if(Python_Development_FOUND)
0056         set(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS})
0057         set(PYTHON_INCLUDE_PATH ${Python_INCLUDE_DIRS})
0058         set(PYTHON_LIBRARY ${Python_LIBRARIES})
0059     endif(Python_Development_FOUND)
0060 
0061     # Auto detect Python site-packages directory
0062     execute_process(COMMAND ${Python_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'))"
0063                     OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_DIR
0064                     OUTPUT_STRIP_TRAILING_WHITESPACE
0065                    )
0066 
0067     message(STATUS "Python system site-packages directory: ${PYTHON_SITE_PACKAGES_DIR}")
0068 
0069     unset(KRITA_PYTHONPATH_V4 CACHE)
0070     unset(KRITA_PYTHONPATH_V5 CACHE)
0071     set(_python_prefix_path ${CMAKE_PREFIX_PATH})
0072     if (WIN32)
0073         foreach(__p ${_python_prefix_path})
0074             set(KRITA_PYTHONPATH_V4 "${__p}/lib/krita-python-libs;${KRITA_PYTHONPATH_V4}")
0075             set(KRITA_PYTHONPATH_V5 "${__p}/Lib/site-packages;${KRITA_PYTHONPATH_V5}")
0076         endforeach()
0077     else()
0078         foreach(__p ${_python_prefix_path})
0079             set(KRITA_PYTHONPATH_V4 "${__p}/lib/krita-python-libs:${KRITA_PYTHONPATH_V4}")
0080             set(KRITA_PYTHONPATH_V5 "${__p}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages:${KRITA_PYTHONPATH_V5}")
0081         endforeach()
0082     endif()
0083 
0084     message(STATUS "Krita site-packages directories for SIP v4: ${KRITA_PYTHONPATH_V4}")
0085     message(STATUS "Krita site-packages directories for SIP v5+: ${KRITA_PYTHONPATH_V5}")
0086 endif()
0087 
0088 find_package_handle_standard_args(PythonLibrary DEFAULT_MSG PYTHON_LIBRARY PYTHON_INCLUDE_DIRS PYTHON_INCLUDE_PATH)
0089 
0090 if(APPLE)
0091     set(CMAKE_FRAMEWORK_PATH ${CMAKE_FRAMEWORK_PATH_OLD})
0092 endif(APPLE)