Skip to content

Commit

Permalink
Use pybind11 for python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinus committed Oct 18, 2018
1 parent b6e2f98 commit 4190fd6
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 296 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lib
build
*.mexa64
*.pyc
.vscode
35 changes: 6 additions & 29 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@

find_package(Boost COMPONENTS python-py35 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_subdirectory(pybind11)

set(Python_ADDITIONAL_VERSIONS "3.5")
find_package(PythonLibs 3 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})

find_package(NumPy REQUIRED)
include_directories(${NUMPY_INCLUDE_DIRS})

add_library( pyopengv SHARED pyopengv.cpp )
target_link_libraries(pyopengv opengv)

set_target_properties(pyopengv PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
SOVERSION ${PROJECT_VERSION}
VERSION ${PROJECT_VERSION}
PREFIX ""
SUFFIX ".so")
if(APPLE)
set_target_properties(pyopengv PROPERTIES
LINK_FLAGS "-undefined dynamic_lookup"
)
target_link_libraries(pyopengv ${Boost_LIBRARIES})
else()
target_link_libraries(pyopengv
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
endif()

pybind11_add_module(pyopengv pyopengv.cpp)
target_link_libraries(pyopengv PRIVATE opengv)


# Find whether to install python libs in site-packages or dist-packages
execute_process ( COMMAND
execute_process( COMMAND
python -c "import distutils.sysconfig; print('dist-packages' if distutils.sysconfig.get_python_lib().endswith('dist-packages') else 'site-packages')"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)

Expand Down
Loading

0 comments on commit 4190fd6

Please sign in to comment.