2020-01-04 23:10:16 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2019-09-01 00:59:55 +00:00
|
|
|
, buildPythonPackage
|
2022-10-23 17:25:42 +00:00
|
|
|
, pythonOlder
|
2019-09-01 00:59:55 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
2021-11-14 04:51:15 +00:00
|
|
|
, boost
|
2021-06-20 12:04:46 +00:00
|
|
|
, eigen
|
|
|
|
, python
|
2019-11-26 22:47:23 +00:00
|
|
|
, catch
|
|
|
|
, numpy
|
2022-01-14 07:00:34 +00:00
|
|
|
, pytestCheckHook
|
2022-10-23 17:25:42 +00:00
|
|
|
, libxcrypt
|
2019-09-01 00:59:55 +00:00
|
|
|
}:
|
2019-01-29 16:44:23 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pybind11";
|
2022-08-09 17:22:19 +00:00
|
|
|
version = "2.10.0";
|
2019-01-29 16:44:23 +00:00
|
|
|
|
2019-09-01 00:59:55 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pybind";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-08-09 17:22:19 +00:00
|
|
|
hash = "sha256-/X8DZPFsNrKGbhjZ1GFOj17/NU6p4R+saCW3pLKVNeA=";
|
2019-01-29 16:44:23 +00:00
|
|
|
};
|
|
|
|
|
2022-08-09 17:22:19 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -i "/^timeout/d" pyproject.toml
|
|
|
|
'';
|
|
|
|
|
2019-10-17 09:44:43 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2022-10-23 17:25:42 +00:00
|
|
|
buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
|
2019-01-29 16:44:23 +00:00
|
|
|
|
2021-06-20 12:04:46 +00:00
|
|
|
dontUseCmakeBuildDir = true;
|
2019-11-26 22:47:23 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2021-11-14 04:51:15 +00:00
|
|
|
"-DBoost_INCLUDE_DIR=${lib.getDev boost}/include"
|
|
|
|
"-DEIGEN3_INCLUDE_DIR=${lib.getDev eigen}/include/eigen3"
|
2021-06-20 12:04:46 +00:00
|
|
|
"-DBUILD_TESTING=on"
|
2022-08-24 21:31:45 +00:00
|
|
|
"-DPYTHON_EXECUTABLE:FILEPATH=${python.pythonForBuild.interpreter}"
|
2020-01-04 23:10:16 +00:00
|
|
|
] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [
|
2021-06-20 12:04:46 +00:00
|
|
|
"-DPYBIND11_CXX_STANDARD=-std=c++17"
|
2019-11-26 22:47:23 +00:00
|
|
|
];
|
|
|
|
|
2021-06-20 12:04:46 +00:00
|
|
|
postBuild = ''
|
|
|
|
# build tests
|
treewide: drop -l$NIX_BUILD_CORES
Passing `-l$NIX_BUILD_CORES` improperly limits the overall system load.
For a build machine which is configured to run `$B` builds where each
build gets `total cores / B` cores (`$C`), passing `-l $C` to make will
improperly limit the load to `$C` instead of `$B * $C`.
This effect becomes quite pronounced on machines with 80 cores, with
40 simultaneous builds and a cores limit of 2. On a machine with this
configuration, Nix will run 40 builds and make will limit the overall
system load to approximately 2. A build machine with this many cores
can happily run with a load approaching 80.
A non-solution is to oversubscribe the machine, by picking a larger
`$C`. However, there is no way to divide the number of cores in a way
which fairly subdivides the available cores when `$B` is greater than
1.
There has been exploration of passing a jobserver in to the sandbox,
or sharing a jobserver between all the builds. This is one option, but
relatively complicated and only supports make. Lots of other software
uses its own implementation of `-j` and doesn't support either `-l` or
the Make jobserver.
For the case of an interactive user machine, the user should limit
overall system load using `$B`, `$C`, and optionally systemd's
cpu/network/io limiting features.
Making this change should significantly improve the utilization of our
build farm, and improve the throughput of Hydra.
2022-09-22 15:17:14 +00:00
|
|
|
make -j $NIX_BUILD_CORES
|
2021-06-20 12:04:46 +00:00
|
|
|
'';
|
2019-11-26 22:47:23 +00:00
|
|
|
|
2021-06-20 12:04:46 +00:00
|
|
|
postInstall = ''
|
2021-06-21 15:51:09 +00:00
|
|
|
make install
|
2019-11-26 22:47:23 +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
|
2019-10-17 09:44:43 +00:00
|
|
|
'';
|
|
|
|
|
2019-11-26 22:47:23 +00:00
|
|
|
checkInputs = [
|
2021-06-20 12:04:46 +00:00
|
|
|
catch
|
2019-11-26 22:47:23 +00:00
|
|
|
numpy
|
2022-01-14 07:00:34 +00:00
|
|
|
pytestCheckHook
|
2019-11-26 22:47:23 +00:00
|
|
|
];
|
|
|
|
|
2022-01-14 07:00:34 +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-02-15 16:39:18 +00:00
|
|
|
# tests that try to parse setuptools stdout
|
|
|
|
"tests/extra_setuptools/test_setuphelper.py"
|
2022-01-14 07:00:34 +00:00
|
|
|
];
|
2021-06-20 12:04:46 +00:00
|
|
|
|
2020-07-07 17:42:07 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://github.com/pybind/pybind11";
|
2022-04-17 18:54:53 +00:00
|
|
|
changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst";
|
2019-01-29 16:44:23 +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-07-07 17:42:07 +00:00
|
|
|
license = licenses.bsd3;
|
2021-06-20 12:04:46 +00:00
|
|
|
maintainers = with maintainers; [ yuriaisaka dotlambda ];
|
2019-01-29 16:44:23 +00:00
|
|
|
};
|
|
|
|
}
|