Commit 17f8a339 authored by Ghislain MARY's avatar Ghislain MARY

Support build of Python module for Python 3.

parent 633d31d8
......@@ -42,6 +42,8 @@ set(ENABLE_NLS NO CACHE BOOL "" FORCE)
set(DEFAULT_VALUE_CMAKE_LINKING_TYPE "-DENABLE_STATIC=YES" "-DENABLE_SHARED=NO")
set(LINPHONE_BUILDER_PYTHON_VERSION "2.7" CACHE STRING "Python version to target")
find_package(Doxygen REQUIRED)
find_package(PythonInterp REQUIRED)
......
......@@ -23,9 +23,9 @@
cmake_minimum_required(VERSION 2.8.12)
project(PYLINPHONE C CXX) # Dummy project
set(Python_ADDITIONAL_VERSIONS 2.7)
set(Python_ADDITIONAL_VERSIONS ${LINPHONE_BUILDER_PYTHON_VERSION})
find_package(PythonInterp REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
find_package(PythonLibs ${LINPHONE_BUILDER_PYTHON_VERSION} REQUIRED)
find_package(Git)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
......@@ -172,6 +172,7 @@ foreach(PACKAGE_TO_BUILD ${PACKAGES_TO_BUILD})
"-DLINPHONE_PYTHON_MODULE=$<TARGET_FILE:pylinphone>" "-DLINPHONE_RESOURCES_PREFIX=${CMAKE_INSTALL_PREFIX}"
"-DLINPHONE_DYNAMIC_LIBRARIES_TO_INSTALL=\"${LINPHONE_DYNAMIC_LIBRARIES_TO_INSTALL}\"" "-DPACKAGE_TYPE=${PACKAGE_TO_BUILD}"
"-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR}" "-DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}" "-DLINPHONE_SOURCE_DIR=${LINPHONE_SOURCE_DIR}"
"-DPYTHON_VERSION_MAJOR=${PYTHON_VERSION_MAJOR}"
"-P" "${CMAKE_CURRENT_SOURCE_DIR}/prepare_packaging.cmake"
)
if(APPLE)
......@@ -253,11 +254,11 @@ add_custom_target(pylinphone_zip ALL DEPENDS "${ZIP_FILENAME}")
install(FILES ${ZIP_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_GIT_REVISION}.${PLATFORM_TAG}-py${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.zip")
# Generate the wheel package
set(WHEEL_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/dist/${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-py2-none-any.whl")
set(WHEEL_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/dist/${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-py${PYTHON_VERSION_MAJOR}-none-any.whl")
add_custom_command(OUTPUT "${WHEEL_FILENAME}"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone/setup.py" "bdist_wheel"
DEPENDS pylinphone
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build_wheel/linphone"
)
add_custom_target(pylinphone_wheel ALL DEPENDS "${WHEEL_FILENAME}")
install(FILES ${WHEEL_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-cp27-none-${UNDERSCORE_PLATFORM_TAG}.whl")
install(FILES ${WHEEL_FILENAME} DESTINATION "." RENAME "${PACKAGE_NAME}-${LINPHONE_UNDERSCORE_GIT_REVISION}-cp${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}-none-${UNDERSCORE_PLATFORM_TAG}.whl")
from linphone import *
from linphone import __version__
from @PACKAGE_PREFIX@linphone import *
from @PACKAGE_PREFIX@linphone import __version__
......@@ -37,5 +37,5 @@ ExternalProject_Add(TARGET_pylinphone
PATCH_COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${CMAKE_CURRENT_LIST_DIR}" "<SOURCE_DIR>"
"COMMAND" "${CMAKE_COMMAND}" "-E" "copy" "${CMAKE_CURRENT_LIST_DIR}/../../cmake/FindXML2.cmake" "<SOURCE_DIR>"
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DPACKAGE_NAME=${PACKAGE_NAME} -DLINPHONE_SOURCE_DIR=${EP_linphone_SOURCE_DIR} -DENABLE_FFMPEG:BOOL=${ENABLE_FFMPEG} -DENABLE_OPENH264:BOOL=${ENABLE_OPENH264} -DENABLE_WASAPI:BOOL=${ENABLE_WASAPI}
CMAKE_ARGS ${LINPHONE_BUILDER_EP_ARGS} -DPACKAGE_NAME=${PACKAGE_NAME} -DLINPHONE_SOURCE_DIR=${EP_linphone_SOURCE_DIR} -DLINPHONE_BUILDER_PYTHON_VERSION=${LINPHONE_BUILDER_PYTHON_VERSION} -DENABLE_FFMPEG:BOOL=${ENABLE_FFMPEG} -DENABLE_OPENH264:BOOL=${ENABLE_OPENH264} -DENABLE_WASAPI:BOOL=${ENABLE_WASAPI}
)
......@@ -35,7 +35,10 @@ endif()
set(OUTPUT_DIR "${OUTPUT_DIR}/build_${PACKAGE_TYPE}/linphone")
file(MAKE_DIRECTORY "${OUTPUT_DIR}/linphone")
configure_file("${INPUT_DIR}/__init__.py.cmake" "${OUTPUT_DIR}/linphone/__init__.py")
if(PYTHON_VERSION_MAJOR GREATER 2)
set(PACKAGE_PREFIX "linphone.") # Add "linphone." prefix to import statements in __init__.py for Python 3
endif()
configure_file("${INPUT_DIR}/__init__.py.cmake" "${OUTPUT_DIR}/linphone/__init__.py" @ONLY)
file(COPY "${LINPHONE_PYTHON_MODULE}" DESTINATION "${OUTPUT_DIR}/linphone")
if(UNIX AND NOT APPLE)
foreach(reallib ${LINPHONE_DYNAMIC_LIBRARIES_TO_INSTALL})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment