2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, buildPythonPackage
|
2022-10-30 15:09:59 +00:00
|
|
|
, pythonOlder
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
2021-12-26 17:43:05 +00:00
|
|
|
, boost
|
2021-06-28 23:13:55 +00:00
|
|
|
, eigen
|
|
|
|
, python
|
2020-04-24 23:36:52 +00:00
|
|
|
, catch
|
|
|
|
, numpy
|
2022-02-10 20:34:41 +00:00
|
|
|
, pytestCheckHook
|
2022-10-30 15:09:59 +00:00
|
|
|
, libxcrypt
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pybind11";
|
2023-01-20 10:41:00 +00:00
|
|
|
version = "2.10.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pybind";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-01-20 10:41:00 +00:00
|
|
|
hash = "sha256-YxAkozyWNTKMCIEk3AhHZbRHtzhRrCSB3wh/Qy9CIyU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -i "/^timeout/d" pyproject.toml
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2022-10-30 15:09:59 +00:00
|
|
|
buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
dontUseCmakeBuildDir = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
# Don't build tests if not needed, read the doInstallCheck value at runtime
|
|
|
|
preConfigure = ''
|
|
|
|
if [ -n "$doInstallCheck" ]; then
|
|
|
|
cmakeFlagsArray+=("-DBUILD_TESTING=ON")
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
cmakeFlags = [
|
2021-12-26 17:43:05 +00:00
|
|
|
"-DBoost_INCLUDE_DIR=${lib.getDev boost}/include"
|
|
|
|
"-DEIGEN3_INCLUDE_DIR=${lib.getDev eigen}/include/eigen3"
|
2022-09-30 11:47:45 +00:00
|
|
|
"-DPYTHON_EXECUTABLE:FILEPATH=${python.pythonForBuild.interpreter}"
|
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
|
2022-10-21 18:38:19 +00:00
|
|
|
make -j $NIX_BUILD_CORES
|
2021-06-28 23:13:55 +00:00
|
|
|
'';
|
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
|
2022-02-10 20:34:41 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# require dependencies not available in nixpkgs
|
|
|
|
"tests/test_embed/test_trampoline.py"
|
|
|
|
"tests/test_embed/test_interpreter.py"
|
|
|
|
# numpy changed __repr__ output of numpy dtypes
|
|
|
|
"tests/test_numpy_dtypes.py"
|
|
|
|
# no need to test internal packaging
|
|
|
|
"tests/extra_python_package/test_files.py"
|
2022-04-15 01:41:22 +00:00
|
|
|
# tests that try to parse setuptools stdout
|
|
|
|
"tests/extra_setuptools/test_setuphelper.py"
|
2022-02-10 20:34:41 +00:00
|
|
|
];
|
2021-06-28 23:13:55 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
disabledTests = lib.optionals (stdenv.isDarwin) [
|
|
|
|
# expects KeyError, gets RuntimeError
|
|
|
|
# https://github.com/pybind/pybind11/issues/4243
|
|
|
|
"test_cross_module_exception_translator"
|
|
|
|
];
|
|
|
|
|
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";
|
2022-04-27 09:35:20 +00:00
|
|
|
changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst";
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|