@@ -5,9 +5,10 @@
55, python
66, pytest
77, cmake
8−, numpy ? null
9−, eigen ? null
10−, scipy ? null
8+, catch
9+, numpy
10+, eigen
11+, scipy
1112}:
1213
1314buildPythonPackage rec {
@@ -21,23 +22,42 @@ buildPythonPackage rec {
2122 sha256 = "0k89w4bsfbpzw963ykg1cyszi3h3nk393qd31m6y46pcfxkqh4rd";
2223 };
2324
24− dontUseCmakeConfigure = true;
25−
2625 nativeBuildInputs = [ cmake ];
27− checkInputs = [ pytest ]
28− ++ (lib.optional (numpy != null) numpy)
29− ++ (lib.optional (eigen != null) eigen)
30− ++ (lib.optional (scipy != null) scipy);
31− checkPhase = ''
32− cmake ${if eigen != null then "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3" else ""}
33− make -j $NIX_BUILD_CORES pytest
34− '';
3526
36− # re-expose the headers to other packages
37− postInstall = ''
38− ln -s $out/include/python${python.pythonVersion}m/pybind11/ $out/include/pybind11
27+ buildInputs = [ catch ];
28+
29+ cmakeFlags = [
30+ "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
31+ ] ++ lib.optionals (!python.isPy2) [
32+ # Enable some tests only on Python 3. The "test_string_view" test
33+ # 'testTypeError: string_view16_chars(): incompatible function arguments'
34+ # fails on Python 2.
35+ "-DPYBIND11_CPP_STANDARD=-std=c++17"
36+ ];
37+
38+ dontUseSetuptoolsBuild = true;
39+ dontUsePipInstall = true;
40+ dontUseSetuptoolsCheck = true;
41+
42+ preFixup = ''
43+ pushd ..
44+ export PYBIND11_USE_CMAKE=1
45+ setuptoolsBuildPhase
46+ pipInstallPhase
47+ # Symlink the CMake-installed headers to the location expected by setuptools
48+ mkdir -p $out/include/${python.libPrefix}
49+ ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
50+ popd
3951 '';
4052
53+ installCheckTarget = "pytest";
54+ doInstallCheck = true;
55+ checkInputs = [
56+ pytest
57+ numpy
58+ scipy
59+ ];
60+
4161 meta = {
4262 homepage = https://github.com/pybind/pybind11;
4363 description = "Seamless operability between C++11 and Python";