1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, cmake
6, eigen
7, python
8, catch
9, numpy
10, pytest
11}:
12
13buildPythonPackage rec {
14 pname = "pybind11";
15 version = "2.8.0";
16
17 src = fetchFromGitHub {
18 owner = "pybind";
19 repo = pname;
20 rev = "v${version}";
21 sha256 = "sha256-kmyfRNZM9AtF0QA1MnWEPwWb6BebkkpanTvQwsraSJo=";
22 };
23
24 nativeBuildInputs = [ cmake ];
25
26 dontUseCmakeBuildDir = true;
27
28 cmakeFlags = [
29 "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
30 "-DBUILD_TESTING=on"
31 ] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [
32 "-DPYBIND11_CXX_STANDARD=-std=c++17"
33 ];
34
35 postBuild = ''
36 # build tests
37 make
38 '';
39
40 postInstall = ''
41 make install
42 # Symlink the CMake-installed headers to the location expected by setuptools
43 mkdir -p $out/include/${python.libPrefix}
44 ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
45 '';
46
47 checkInputs = [
48 catch
49 numpy
50 pytest
51 ];
52
53 checkPhase = ''
54 runHook preCheck
55
56 make check
57
58 runHook postCheck
59 '';
60
61 meta = with lib; {
62 homepage = "https://github.com/pybind/pybind11";
63 description = "Seamless operability between C++11 and Python";
64 longDescription = ''
65 Pybind11 is a lightweight header-only library that exposes
66 C++ types in Python and vice versa, mainly to create Python
67 bindings of existing C++ code.
68 '';
69 license = licenses.bsd3;
70 maintainers = with maintainers; [ yuriaisaka dotlambda ];
71 };
72}