Skip to content

Commit

Permalink
Ensure proper Pybind11 is found. (#1961)
Browse files Browse the repository at this point in the history
* Add pybind11 version to config.
* Add version check for PB11.
* Bump CMake a tiny bit.
  • Loading branch information
thorstenhater authored Sep 20, 2022
1 parent 1a6f44d commit 8b388e6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
cc: "gcc-8",
cxx: "g++-8",
py: "3.7",
cmake: "3.18.x",
cmake: "3.19.x",
mpi: "ON",
simd: "OFF"
}
Expand All @@ -29,7 +29,7 @@ jobs:
cc: "clang-8",
cxx: "clang++-8",
py: "3.7",
cmake: "3.18.x",
cmake: "3.19.x",
mpi: "ON",
simd: "OFF"
}
Expand All @@ -39,7 +39,7 @@ jobs:
cc: "clang",
cxx: "clang++",
py: "3.7",
cmake: "3.18.x",
cmake: "3.19.x",
mpi: "ON",
simd: "OFF"
}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.19)
include(CMakeDependentOption)

# Make CUDA support throw errors if architectures remain unclear
Expand Down
14 changes: 14 additions & 0 deletions doc/install/build_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,20 @@ on your target system that are not covered here, please make an issue on the
Arbor `Github issues <https://github.com/arbor-sim/arbor/issues>`_ page.
We will do our best to help you directly, and update this guide to help other users.

.. warn::

On many HPC systems a tool called ``module`` or ``ml`` is installed, which
use the ``CPATH`` environment variable to set up include paths for building.
The contents of this variable are forced on all compilations and by extension
to dependency generation. This can lead to the wrong headers being picked up
despite ``CMake`` reporting the correct versions, which can produce spurious
errors.

If you are using one of these tools (and possibly ```easybuid``) and encounter
such problems, try to ``module unload`` as many modules as possibe. One example
has been found with JSC clusters and an outdated pybind11 which was brought in
by ``ml SciPy-Stack``.

.. _install-mpi:

MPI
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(ARB_USE_BUNDLED_PYBIND11)
# instead of using find_package.
add_subdirectory(${pb11_src_dir} pybind11)
else()
find_package(pybind11 REQUIRED)
find_package(pybind11 2.8.1 REQUIRED)
endif()

set(pyarb_source
Expand Down
10 changes: 10 additions & 0 deletions python/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ pybind11::dict config() {
dict[pybind11::str("version")] = pybind11::str(ARB_VERSION);
dict[pybind11::str("source")] = pybind11::str(ARB_SOURCE_ID);
dict[pybind11::str("arch")] = pybind11::str(ARB_ARCH);
{
#define mk_tok(x) #x
#define mk_ver(M, m, p) mk_tok(M) "." mk_tok(m) "." mk_tok(p)
const char* version = mk_ver(PYBIND11_VERSION_MAJOR,
PYBIND11_VERSION_MINOR,
PYBIND11_VERSION_PATCH);
dict[pybind11::str("pybind-version")] = pybind11::str(version);
#undef mk_ver
#undef mk_tok
}
return dict;
}

Expand Down
12 changes: 12 additions & 0 deletions python/pyarb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@

#include <pybind11/pybind11.h>

// Version check
#define mk_tok(x) #x
#define mk_ver(M, m, p) mk_tok(M) "." mk_tok(m) "." mk_tok(p)
#define PB11_ERR(M, m, p) "Required version of pybind11 is 2.8.1 <= version < 3.0.0 Found " mk_ver(M, m, p)
static_assert((PYBIND11_VERSION_HEX >= 0x02080100)
&&
(PYBIND11_VERSION_HEX < 0x03000000),
PB11_ERR(PYBIND11_VERSION_MAJOR, PYBIND11_VERSION_MINOR, PYBIND11_VERSION_PATCH));
#undef PB11_ERR
#undef mk_ver
#undef mk_tok

namespace pyarb {

// Sample recorder object interface.
Expand Down
2 changes: 1 addition & 1 deletion spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Arbor(CMakePackage, CudaPackage):
conflicts("%cce@:9.1")
conflicts("%intel")

depends_on("cmake@3.12:", type="build")
depends_on("cmake@3.19:", type="build")

# misc dependencies
depends_on("fmt@7.1:", when="@0.5.3:") # required by the modcc compiler
Expand Down

0 comments on commit 8b388e6

Please sign in to comment.