Skip to content

Commit

Permalink
PYBIND11_FINDPYTHON=ON
Browse files Browse the repository at this point in the history
Reuse our `find_package(Python ...)` call and use new CMake logic in
pybind11.
https://pybind11.readthedocs.io/en/stable/compiling.html#modules-with-cmake

Signed-off-by: Axel Huebl <[email protected]>
  • Loading branch information
ax3l committed Oct 11, 2024
1 parent 9806b04 commit de3b2a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
python3.exe -m pip install --upgrade cmake
python3.exe -m pip install --upgrade numpy
python3.exe -m pip wheel .
python3.exe -m pip wheel -v .
if(!$?) { Exit $LASTEXITCODE }
python3.exe -m pip install openPMD_api-0.16.0-cp39-cp39-win_amd64.whl
python3.exe -m pip install -v openPMD_api-0.16.0-cp39-cp39-win_amd64.whl
if(!$?) { Exit $LASTEXITCODE }
python3.exe -c "import openpmd_api as api; print(api.variants)"
Expand Down
5 changes: 5 additions & 0 deletions cmake/dependencies/pybind11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function(find_pybind11)
message(STATUS "pybind11 repository: ${openPMD_pybind11_repo} (${openPMD_pybind11_branch})")
endif()
endif()

# rely on our find_package(Python ...) call
# https://pybind11.readthedocs.io/en/stable/compiling.html#modules-with-cmake
set(PYBIND11_FINDPYTHON ON)

if(TARGET pybind11::module)
# nothing to do, target already exists in the superbuild
elseif(openPMD_USE_INTERNAL_PYBIND11 AND openPMD_pybind11_src)
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ def build_extension(self, ext):
extdir += os.path.sep

cmake_args = [
# Python: use the calling interpreter in CMake
# https://cmake.org/cmake/help/latest/module/FindPython.html#hints
'-DPython_ROOT_DIR=' + sys.prefix,
'-DPython_FIND_STRATEGY=LOCATION",
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' +
os.path.join(extdir, "openpmd_api"),
# '-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=' + extdir,
'-DopenPMD_PYTHON_OUTPUT_DIRECTORY=' + extdir,
'-DPython_EXECUTABLE=' + sys.executable,
'-DopenPMD_USE_PYTHON:BOOL=ON',
# variants
'-DopenPMD_USE_MPI:BOOL=' + openPMD_USE_MPI,
Expand Down

0 comments on commit de3b2a5

Please sign in to comment.