Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python binding でSIGSEGVが発生した場合の対応方法 #58

Open
tmori opened this issue Sep 3, 2024 · 3 comments
Open

Python binding でSIGSEGVが発生した場合の対応方法 #58

tmori opened this issue Sep 3, 2024 · 3 comments

Comments

@tmori
Copy link
Contributor

tmori commented Sep 3, 2024

対応方法

CMakeLists.txtでPythonのバージョンと利用するPythonバージョンが一致しないとSIGSEGVで落ちますので、以下のように対応できます。

cmake_minimum_required(VERSION 3.12)

project(hakoniwa_python_project
    LANGUAGES C CXX
)

# PythonのバージョンがCMakeで指定されているかどうかを確認
if(${CMAKE_VERSION} LESS 3.12)
    find_package(PythonLibs REQUIRED)
    include_directories(${PYTHON_INCLUDE_DIRS})
    set(HAKO_PYTHON_LIBS ${PYTHON_LIBRARIES})
else()
    set(Python3_EXECUTABLE "$ENV{HOME}/.pyenv/versions/3.10.0/bin/python3.10")
    set(Python3_INCLUDE_DIRS "$ENV{HOME}/.pyenv/versions/3.10.0/include/python3.10")
    set(Python3_LIBRARIES "$ENV{HOME}/.pyenv/versions/3.10.0/lib/libpython3.10.dylib")
    find_package(Python3 3.10 EXACT REQUIRED)

    include_directories(${Python3_INCLUDE_DIRS})
    set(HAKO_PYTHON_LIBS ${Python3_LIBRARIES})

    # Debugging messages
    message(STATUS "Python3_VERSION: ${Python3_VERSION}")
    message(STATUS "Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}")
endif()

message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
message(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")
message(STATUS "Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}")
message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
message(STATUS "Python_LIBRARIES: ${Python_LIBRARIES}")
message(STATUS "Python_LIBRARY_DIRS: ${Python_LIBRARY_DIRS}")

add_library(
    hako_asset_python SHARED
    hako_asset_python.cpp
)

target_link_libraries(
    hako_asset_python 
    assets
    ${HAKO_PYTHON_LIBS}
)
@tmori
Copy link
Contributor Author

tmori commented Sep 3, 2024

condaは実績ありません。

SIGSEGVで落ちます。

@tmori
Copy link
Contributor Author

tmori commented Sep 3, 2024

Windowsはpyenvがないと思われるので、面倒ですね。

@tmori
Copy link
Contributor Author

tmori commented Sep 3, 2024

CMAKE_VERSIONは、3.12以降にしたい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant