Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, fetchpatch
6, python
7, pytest
8, cmake
9, catch
10, numpy
11, eigen
12, scipy
13}:
14
15buildPythonPackage rec {
16 pname = "pybind11";
17 version = "2.5.0";
18
19 src = fetchFromGitHub {
20 owner = "pybind";
21 repo = pname;
22 rev = "v${version}";
23 sha256 = "13hcj6g7k7yvj7nry2ar6f5mg58ln7frrvq1cg5f8mczxh1ch6zl";
24 };
25
26 nativeBuildInputs = [ cmake ];
27
28 buildInputs = [ catch ];
29
30 cmakeFlags = [
31 "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
32 ] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [
33 # Enable some tests only on Python 3. The "test_string_view" test
34 # 'testTypeError: string_view16_chars(): incompatible function arguments'
35 # fails on Python 2.
36 "-DPYBIND11_CPP_STANDARD=-std=c++17"
37 ];
38
39 dontUseSetuptoolsBuild = true;
40 dontUsePipInstall = true;
41 dontUseSetuptoolsCheck = true;
42
43 preFixup = ''
44 pushd ..
45 export PYBIND11_USE_CMAKE=1
46 setuptoolsBuildPhase
47 pipInstallPhase
48 # Symlink the CMake-installed headers to the location expected by setuptools
49 mkdir -p $out/include/${python.libPrefix}
50 ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
51 popd
52 '';
53
54 checkInputs = [
55 pytest
56 numpy
57 scipy
58 ];
59
60 meta = with lib; {
61 homepage = "https://github.com/pybind/pybind11";
62 description = "Seamless operability between C++11 and Python";
63 longDescription = ''
64 Pybind11 is a lightweight header-only library that exposes
65 C++ types in Python and vice versa, mainly to create Python
66 bindings of existing C++ code.
67 '';
68 license = licenses.bsd3;
69 maintainers = with maintainers;[ yuriaisaka ];
70 };
71}