Skip to content

Commit

Permalink
feat: upgrade to python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadikum committed Aug 24, 2022
1 parent 74ce4fe commit 3a7d18d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(vera++)
cmake_minimum_required(VERSION 2.8.6)
cmake_minimum_required(VERSION 3.12)

set(VERA_MAJOR 1)
set(VERA_MINOR 3)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ target_link_libraries(vera
${TCL_LIBRARY}
${Boost_LIBRARIES})
if(VERA_PYTHON)
target_link_libraries(vera ${PYTHON_LIBRARIES})
target_link_libraries(vera ${Python3_LIBRARIES})
endif()
if(VERA_LUA)
target_link_libraries(vera ${LUA_LIBRARIES} ${LUABIND_LIBRARY})
Expand Down
9 changes: 5 additions & 4 deletions src/boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ endif()
mark_as_advanced(VERA_USE_SYSTEM_BOOST)

set(boostLibs filesystem system program_options regex wave)
set(pythonLib "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
if(VERA_PYTHON)
# Note that Boost Python components require a Python version
# suffix (Boost 1.67 and later), e.g. python36 or python27 for
Expand All @@ -17,7 +18,7 @@ if(VERA_PYTHON)
# be used as suffixes, but note that they are not portable.
#
# from https://cmake.org/cmake/help/latest/module/FindBoost.html
list(APPEND boostLibs python39)
list(APPEND boostLibs ${pythonLib})
endif()

if(VERA_USE_SYSTEM_BOOST)
Expand Down Expand Up @@ -49,7 +50,7 @@ else()
set(Boost_URL "https://${BOOST_MIRROR}/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2")
set(Boost_URL_HASH "SHA256=fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854")

string(REPLACE "python39" "python" boostLibs "${boostLibs}")
string(REPLACE ${pythonLib} "python" boostLibs "${boostLibs}")
string(REPLACE ";" "," boostLibsComma "${boostLibs}")
string(REPLACE ";" " --with-" WITH_LIBS "${boostLibs}")
set(WITH_LIBS "--with-${WITH_LIBS}")
Expand Down Expand Up @@ -80,7 +81,7 @@ else()
# generate the project-config.jam
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/project-config.jam.in ${CMAKE_CURRENT_BINARY_DIR}/project-config.jam @ONLY)
if(VERA_PYTHON)
set(b2ExtraFlags include=${PYTHON_INCLUDE_DIR})
set(b2ExtraFlags include=${Python3_INCLUDE_DIRS})
string(REPLACE ",python" "" boostLibsComma "${boostLibsComma}")
else()
set(b2ExtraFlags)
Expand All @@ -91,7 +92,7 @@ else()
# Starting with Boost 1.67, Boost Python's libary includes a version suffix.
if(NOT (Boost_VERSION VERSION_LESS 1.67))
if (${l} STREQUAL "python")
set(l "python39")
set(l ${pythonLib})
endif()
endif()
if(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/project-config.jam.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if ! @TOOLSET@ in [ feature.values <toolset> ]
project : default-build <toolset>@TOOLSET@ ;

# Python configuration
using python : @PYTHON_VERSION@ : @PYTHON_EXECUTABLE@ : @PYTHON_INCLUDE_DIR@ ;
using python : @Python3_VERSION@ : @Python3_EXECUTABLE@ : @Python3_INCLUDE_DIRS@ ;

libraries = @WITH_LIBS@ ;

Expand Down
39 changes: 19 additions & 20 deletions src/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ mark_as_advanced(VERA_USE_SYSTEM_PYTHON)

if(VERA_USE_SYSTEM_PYTHON)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(PythonInterp 3)
find_package(PythonLibs 3)
if(WIN32 AND NOT PYTHONLIBS_FOUND)
find_package(Python3 COMPONENTS Interpreter Development)
if(NOT Python3_FOUND)
message(FATAL_ERROR "Could NOT find Python. Turn VERA_USE_SYSTEM_PYTHON to OFF to build it with vera++.")
endif()
include_directories(BEFORE SYSTEM ${PYTHON_INCLUDE_DIR})
link_directories(${PYTHON_LIBRARY_DIR})
include_directories(BEFORE SYSTEM ${Python3_INCLUDE_DIRS})
link_directories(${Python3_LIBRARY_DIRS})
# no target
set(Python_TARGET)
else()
Expand Down Expand Up @@ -130,33 +129,33 @@ else()
# copy the runtime near vera++ executable so we can run the tests
ExternalProject_Add_Step(python install_dll
COMMAND ${CMAKE_COMMAND} -E copy
${INSTALL_DIR}/bin/python39.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/python39.dll
${INSTALL_DIR}/bin/python310.dll
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/python310.dll
DEPENDEES install)
ExternalProject_Add_Step(python install_libs
COMMAND ${CMAKE_COMMAND} -E copy_directory
${INSTALL_DIR}/lib
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/lib
DEPENDEES install)
set(PYTHON_EXECUTABLE ${INSTALL_DIR}/bin/python.exe)
set(PYTHON_LIBRARIES debug ${BINARY_DIR}/libs/Debug/python39.lib
optimized ${BINARY_DIR}/libs/Release/python39.lib)
set(PYTHON_INCLUDE_DIR ${INSTALL_DIR}/include)
list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS "${INSTALL_DIR}/bin/python39.dll")
set(Python3_EXECUTABLE ${INSTALL_DIR}/bin/python.exe)
set(Python3_LIBRARIES debug ${BINARY_DIR}/libs/Debug/python310.lib
optimized ${BINARY_DIR}/libs/Release/python310.lib)
set(Python3_INCLUDE_DIRS ${INSTALL_DIR}/include)
list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS "${INSTALL_DIR}/bin/python310.dll")
install(DIRECTORY ${INSTALL_DIR}/lib DESTINATION bin)
elseif(APPLE)
message(WARNING "Python won't be installed. Setting VERA_USE_SYSTEM_PYTHON to OFF should only be used for testing purpose on this system.")
set(PYTHON_EXECUTABLE ${INSTALL_DIR}/bin/python)
set(PYTHON_LIBRARIES ${INSTALL_DIR}/lib/libpython3.9.dylib)
set(PYTHON_INCLUDE_DIR ${INSTALL_DIR}/include/python3.9)
set(Python3_EXECUTABLE ${INSTALL_DIR}/bin/python)
set(Python3_LIBRARIES ${INSTALL_DIR}/lib/libpython3.10.dylib)
set(Python3_INCLUDE_DIRS ${INSTALL_DIR}/include/python3.10)
else()
message(WARNING "Python won't be installed. Setting VERA_USE_SYSTEM_PYTHON to OFF should only be used for testing purpose on this system.")
set(PYTHON_EXECUTABLE ${INSTALL_DIR}/bin/python)
set(PYTHON_LIBRARIES ${INSTALL_DIR}/lib/libpython3.9.so)
set(PYTHON_INCLUDE_DIR ${INSTALL_DIR}/include/python3.9)
set(Python3_EXECUTABLE ${INSTALL_DIR}/bin/python)
set(Python3_LIBRARIES ${INSTALL_DIR}/lib/libpython3.10.so)
set(Python3_INCLUDE_DIRS ${INSTALL_DIR}/include/python3.10)
endif()
set(PYTHON_VERSION 3.9.7)
include_directories(SYSTEM ${PYTHON_INCLUDE_DIR})
set(Python3_VERSION 3.10.4)
include_directories(SYSTEM ${Python3_INCLUDE_DIRS})
link_directories(${BINARY_DIR})
set(Python_TARGET python)
endif()
Expand Down

0 comments on commit 3a7d18d

Please sign in to comment.