Skip to content

Commit f556879

Browse files
authored
1 parent baf32f3 commit f556879

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ endif()
254254

255255
# Python
256256
if(WarpX_PYTHON)
257-
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
257+
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
258258

259259
# default installation directories: Python
260260
warpx_set_default_install_dirs_python()

cmake/dependencies/pybind11.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ function(find_pybind11)
1010
message(STATUS "pybind11 repository: ${WarpX_pybind11_repo} (${WarpX_pybind11_branch})")
1111
include(FetchContent)
1212
endif()
13+
14+
# rely on our find_package(Python ...) call
15+
# https://pybind11.readthedocs.io/en/stable/compiling.html#modules-with-cmake
16+
set(PYBIND11_FINDPYTHON ON)
17+
1318
if(WarpX_pybind11_internal OR WarpX_pybind11_src)
1419
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
1520

setup.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,15 @@ def build_extension(self, ext):
8484
r_dim = re.search(r"warpx_(1|2|rz|3)(?:d*)", ext.name)
8585
dims = r_dim.group(1).upper()
8686

87+
pyv = sys.version_info
8788
cmake_args = [
89+
# Python: use the calling interpreter in CMake
90+
# https://cmake.org/cmake/help/latest/module/FindPython.html#hints
91+
# https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-version-selection
92+
f"-DPython_ROOT_DIR={sys.prefix}",
93+
f"-DPython_FIND_VERSION={pyv.major}.{pyv.minor}.{pyv.micro}",
94+
"-DPython_FIND_VERSION_EXACT=TRUE",
95+
"-DPython_FIND_STRATEGY=LOCATION",
8896
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + os.path.join(extdir, "pywarpx"),
8997
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=" + extdir,
9098
"-DWarpX_DIMS=" + dims,

0 commit comments

Comments
 (0)