nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, cmake
6, boost
7, eigen
8, python
9, catch
10, numpy
11, pytestCheckHook
12}:
13
14buildPythonPackage rec {
15 pname = "pybind11";
16 version = "2.9.2";
17
18 src = fetchFromGitHub {
19 owner = "pybind";
20 repo = pname;
21 rev = "v${version}";
22 hash = "sha256-O3bkexUBa+gfiJEM6KSR8y/iVqHqlCFmz/9EghxdIpw=";
23 };
24
25 nativeBuildInputs = [ cmake ];
26
27 dontUseCmakeBuildDir = true;
28
29 cmakeFlags = [
30 "-DBoost_INCLUDE_DIR=${lib.getDev boost}/include"
31 "-DEIGEN3_INCLUDE_DIR=${lib.getDev eigen}/include/eigen3"
32 "-DBUILD_TESTING=on"
33 ] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [
34 "-DPYBIND11_CXX_STANDARD=-std=c++17"
35 ];
36
37 postBuild = ''
38 # build tests
39 make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES
40 '';
41
42 postInstall = ''
43 make install
44 # Symlink the CMake-installed headers to the location expected by setuptools
45 mkdir -p $out/include/${python.libPrefix}
46 ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
47 '';
48
49 checkInputs = [
50 catch
51 numpy
52 pytestCheckHook
53 ];
54
55 disabledTestPaths = [
56 # require dependencies not available in nixpkgs
57 "tests/test_embed/test_trampoline.py"
58 "tests/test_embed/test_interpreter.py"
59 # numpy changed __repr__ output of numpy dtypes
60 "tests/test_numpy_dtypes.py"
61 # no need to test internal packaging
62 "tests/extra_python_package/test_files.py"
63 # tests that try to parse setuptools stdout
64 "tests/extra_setuptools/test_setuphelper.py"
65 ];
66
67 meta = with lib; {
68 homepage = "https://github.com/pybind/pybind11";
69 changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst";
70 description = "Seamless operability between C++11 and Python";
71 longDescription = ''
72 Pybind11 is a lightweight header-only library that exposes
73 C++ types in Python and vice versa, mainly to create Python
74 bindings of existing C++ code.
75 '';
76 license = licenses.bsd3;
77 maintainers = with maintainers; [ yuriaisaka dotlambda ];
78 };
79}