This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Switch Python bindings to pybind11. #57
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a826281
Switch Python bindings to pybind11.
matz-e f49dc3c
fixup! Switch Python bindings to pybind11.
matz-e 5b7aa4e
Detect version via python.
matz-e a88d603
Use test image.
matz-e 0e52198
Add forgotten unit test variable change.
matz-e 119649e
Move back to proper docker image for CI
matz-e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.eggs | ||
.pytest_cache | ||
*.egg-info | ||
__pycache__ | ||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "python/pybind11"] | ||
path = python/pybind11 | ||
url = https://github.com/pybind/pybind11.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,5 @@ | ||
############################################## | ||
# Requirements | ||
find_package(PythonComplete QUIET) | ||
find_package(Cython REQUIRED) | ||
|
||
|
||
|
||
|
||
|
||
############################################## | ||
# Definitions | ||
set(cymod_src "${CMAKE_CURRENT_SOURCE_DIR}/mvdtool.pyx") | ||
set(default_cybindings_cpp "${CMAKE_CURRENT_SOURCE_DIR}/mvdtool.cpp") | ||
set(cybindings_cpp "${CMAKE_CURRENT_BINARY_DIR}/mvdtool.cpp") | ||
set(local_include_dir "${CMAKE_CURRENT_SOURCE_DIR}/include") | ||
set(cy_sources | ||
mvdtool.pyx | ||
include/boost.pxd | ||
include/MVD2.pxd | ||
include/MVD3.pxd | ||
include/MVD_MVDType.pxd | ||
include/MVD.pxd | ||
include/std.pxd) | ||
|
||
############################################## | ||
# Rules | ||
|
||
# .pyx -> .cpp | ||
add_custom_command( | ||
OUTPUT ${cybindings_cpp} | ||
COMMAND ${CYTHON_EXECUTABLE} ${CYTHON_FLAGS} --fast-fail --cplus -I${local_include_dir} --output-file ${cybindings_cpp} ${cymod_src} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
# No dependencies, except own sources | ||
DEPENDS ${cy_sources} | ||
COMMENT "Cythonizing ${cymod_src}" | ||
) | ||
|
||
# .cpp -> shared_lib | ||
add_definitions("-std=c++11" "-Wfatal-errors" "-Wno-strict-aliasing") | ||
python_add_module(mvdtool ${cybindings_cpp}) | ||
target_include_directories(mvdtool PRIVATE ${PYTHON_INCLUDE_DIRS} ${local_include_dir}) | ||
target_link_libraries(mvdtool MVDTool) | ||
|
||
|
||
############################################## | ||
# Python packaging | ||
|
||
get_target_property(_include_dirs mvd-tool INCLUDE_DIRECTORIES) | ||
set(_inc_str ${local_include_dir}) | ||
foreach(dir ${_include_dirs}) | ||
set(_inc_str "${_inc_str}:${dir}") | ||
endforeach() | ||
|
||
# Wheel | ||
add_custom_target(pydist | ||
COMMAND python setup.py build --build-base=${CMAKE_CURRENT_BINARY_DIR} build_ext "-I${_inc_str}" bdist_wheel --dist-dir ${CMAKE_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DEPENDS ${cybindings_cpp} | ||
COMMENT "Building distributable Python wheel in ${CMAKE_BINARY_DIR}" | ||
) | ||
|
||
# Source dist - still requires include dirs | ||
add_custom_target(pysrcdist | ||
COMMAND python setup.py build --build-base=${CMAKE_CURRENT_BINARY_DIR} sdist --dist-dir ${CMAKE_BINARY_DIR} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
DEPENDS ${cybindings_cpp} | ||
COMMENT "Building distributable Python wheel in ${CMAKE_BINARY_DIR}" | ||
) | ||
|
||
|
||
############################################## | ||
# Install | ||
# | ||
install(TARGETS mvdtool | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_PYTHON_PACKAGES} ) | ||
|
||
|
||
############################################## | ||
# TESTS | ||
# | ||
add_test(NAME python_read_mvd2 | ||
COMMAND bash -c "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} python test/read_mvd2.py" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
add_test(NAME python_read_mvd3 | ||
COMMAND bash -c "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} python test/read_mvd3.py" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
add_subdirectory(pybind11) | ||
|
||
pybind11_add_module(mvdtool mvdtool.cpp) | ||
target_link_libraries(mvdtool PUBLIC MVDTool HighFive) | ||
install(TARGETS mvdtool DESTINATION lib/python) |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check out this instead:
https://github.com/BlueBrain/nmodl/blob/master/cmake/FindPythonModule.cmake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but isn't that for module dependencies? We're trying to get just the version out of
setup.py
, without requiring any python modules to be installed, really.