Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, buildPythonPackage
4, pythonOlder
5, fetchFromGitHub
6, cmake
7, boost
8, eigen
9, python
10, catch
11, numpy
12, pytestCheckHook
13, libxcrypt
14}:
15
16buildPythonPackage rec {
17 pname = "pybind11";
18 version = "2.10.1";
19
20 src = fetchFromGitHub {
21 owner = "pybind";
22 repo = pname;
23 rev = "v${version}";
24 hash = "sha256-9NS0/fLW2zEmEXhI9GfNN3C/CeI5xibFHwMoUebI90U=";
25 };
26
27 postPatch = ''
28 sed -i "/^timeout/d" pyproject.toml
29 '';
30
31 nativeBuildInputs = [ cmake ];
32 buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
33
34 dontUseCmakeBuildDir = true;
35
36 # Don't build tests if not needed, read the doInstallCheck value at runtime
37 preConfigure = ''
38 if [ -n "$doInstallCheck" ]; then
39 cmakeFlagsArray+=("-DBUILD_TESTING=ON")
40 fi
41 '';
42
43 cmakeFlags = [
44 "-DBoost_INCLUDE_DIR=${lib.getDev boost}/include"
45 "-DEIGEN3_INCLUDE_DIR=${lib.getDev eigen}/include/eigen3"
46 "-DPYTHON_EXECUTABLE:FILEPATH=${python.pythonForBuild.interpreter}"
47 ] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [
48 "-DPYBIND11_CXX_STANDARD=-std=c++17"
49 ];
50
51 postBuild = ''
52 # build tests
53 make -j $NIX_BUILD_CORES
54 '';
55
56 postInstall = ''
57 make install
58 # Symlink the CMake-installed headers to the location expected by setuptools
59 mkdir -p $out/include/${python.libPrefix}
60 ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
61 '';
62
63 checkInputs = [
64 catch
65 numpy
66 pytestCheckHook
67 ];
68
69 disabledTestPaths = [
70 # require dependencies not available in nixpkgs
71 "tests/test_embed/test_trampoline.py"
72 "tests/test_embed/test_interpreter.py"
73 # numpy changed __repr__ output of numpy dtypes
74 "tests/test_numpy_dtypes.py"
75 # no need to test internal packaging
76 "tests/extra_python_package/test_files.py"
77 # tests that try to parse setuptools stdout
78 "tests/extra_setuptools/test_setuphelper.py"
79 ];
80
81 meta = with lib; {
82 homepage = "https://github.com/pybind/pybind11";
83 changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst";
84 description = "Seamless operability between C++11 and Python";
85 longDescription = ''
86 Pybind11 is a lightweight header-only library that exposes
87 C++ types in Python and vice versa, mainly to create Python
88 bindings of existing C++ code.
89 '';
90 license = licenses.bsd3;
91 maintainers = with maintainers; [ yuriaisaka dotlambda ];
92 };
93}