2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
2021-06-28 23:13:55 +00:00
|
|
|
, eigen
|
|
|
|
, python
|
2020-04-24 23:36:52 +00:00
|
|
|
, catch
|
|
|
|
, numpy
|
2021-06-28 23:13:55 +00:00
|
|
|
, pytest
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pybind11";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "2.8.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pybind";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "sha256-kmyfRNZM9AtF0QA1MnWEPwWb6BebkkpanTvQwsraSJo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
dontUseCmakeBuildDir = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
|
2021-06-28 23:13:55 +00:00
|
|
|
"-DBUILD_TESTING=on"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [
|
2021-06-28 23:13:55 +00:00
|
|
|
"-DPYBIND11_CXX_STANDARD=-std=c++17"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
postBuild = ''
|
|
|
|
# build tests
|
|
|
|
make
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
postInstall = ''
|
|
|
|
make install
|
2020-04-24 23:36:52 +00:00
|
|
|
# Symlink the CMake-installed headers to the location expected by setuptools
|
|
|
|
mkdir -p $out/include/${python.libPrefix}
|
|
|
|
ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkInputs = [
|
2021-06-28 23:13:55 +00:00
|
|
|
catch
|
2020-04-24 23:36:52 +00:00
|
|
|
numpy
|
2021-06-28 23:13:55 +00:00
|
|
|
pytest
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
make check
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/pybind/pybind11";
|
|
|
|
description = "Seamless operability between C++11 and Python";
|
|
|
|
longDescription = ''
|
|
|
|
Pybind11 is a lightweight header-only library that exposes
|
|
|
|
C++ types in Python and vice versa, mainly to create Python
|
|
|
|
bindings of existing C++ code.
|
|
|
|
'';
|
2020-08-20 17:08:02 +00:00
|
|
|
license = licenses.bsd3;
|
2021-06-28 23:13:55 +00:00
|
|
|
maintainers = with maintainers; [ yuriaisaka dotlambda ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|