1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, fetchpatch
5, python
6, pytest
7, cmake
8, numpy ? null
9, eigen ? null
10, scipy ? null
11}:
12
13buildPythonPackage rec {
14 pname = "pybind11";
15 version = "2.3.0";
16
17 src = fetchFromGitHub {
18 owner = "pybind";
19 repo = pname;
20 rev = "v${version}";
21 sha256 = "11b6dniri8m05spfd2a19irz82shf4sdca73566bniggrf3zclnf";
22 };
23
24 patches = [
25 (fetchpatch {
26 url = https://github.com/pybind/pybind11/commit/44a40dd61e5178985cfb1150cf05e6bfcec73042.patch;
27 sha256 = "047nzyfsihswdva96hwchnp4gj2mlbiqvmkdnhxrfi9sji8x31ka";
28 })
29 (fetchpatch {
30 name = "pytest-4-excinfo-fix.patch";
31 url = https://github.com/pybind/pybind11/commit/9fd4712121fdbb6202a35be4c788525e6c8ab826.patch;
32 sha256 = "07jjv8jlbszvr2grpm5xqxjac7jb0y68lgb1jcbb93k9vyp1hr33";
33 })
34 ];
35
36 dontUseCmakeConfigure = true;
37
38 checkInputs = [ pytest cmake ]
39 ++ (lib.optional (numpy != null) numpy)
40 ++ (lib.optional (eigen != null) eigen)
41 ++ (lib.optional (scipy != null) scipy);
42 checkPhase = ''
43 cmake ${if eigen != null then "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3" else ""}
44 make -j $NIX_BUILD_CORES pytest
45 '';
46
47 meta = {
48 homepage = https://github.com/pybind/pybind11;
49 description = "Seamless operability between C++11 and Python";
50 longDescription = ''
51 Pybind11 is a lightweight header-only library that exposes
52 C++ types in Python and vice versa, mainly to create Python
53 bindings of existing C++ code.
54 '';
55 license = lib.licenses.bsd3;
56 maintainers = [ lib.maintainers.yuriaisaka ];
57 };
58}