Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 55 additions & 37 deletions pkgs/development/python-modules/pybind11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
fetchFromGitHub,
cmake,
ninja,
setuptools,
scikit-build-core,
pybind11,
boost,
eigen,
python,
catch,
catch2,
numpy,
pytestCheckHook,
libxcrypt,
Expand All @@ -29,38 +30,46 @@ let
in
buildPythonPackage rec {
pname = "pybind11";
version = "2.13.6";
version = "3.0.0";
pyproject = true;

src = fetchFromGitHub {
owner = "pybind";
repo = "pybind11";
tag = "v${version}";
hash = "sha256-SNLdtrOjaC3lGHN9MAqTf51U9EzNKQLyTMNPe0GcdrU=";
hash = "sha256-uyeBTZL38kXIoNxZBWcMRx046+tVJ4ZmCOwGz+D2XJA=";
};

build-system = [
cmake
ninja
setuptools
pybind11.passthru.scikit-build-core-no-tests
];

buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
buildInputs =
[
# Used only for building tests - something we do even when cross
# compiling.
catch2
boost
eigen
]
++ lib.optionals (pythonOlder "3.9") [
libxcrypt
];
propagatedNativeBuildInputs = [ setupHook ];

dontUseCmakeBuildDir = true;

# Don't build tests if not needed, read the doInstallCheck value at runtime
preConfigure = ''
if [ -n "$doInstallCheck" ]; then
cmakeFlagsArray+=("-DBUILD_TESTING=ON")
fi
'';

cmakeFlags = [
"-DBoost_INCLUDE_DIR=${lib.getDev boost}/include"
"-DEIGEN3_INCLUDE_DIR=${lib.getDev eigen}/include/eigen3"
] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [ "-DPYBIND11_CXX_STANDARD=-std=c++17" ];
env = {
SKBUILD_CMAKE_ARGS = lib.strings.concatStringsSep ";" [
# Always build tests, because even when cross compiling building the tests
# is another confirmation that everything is OK.
(lib.cmakeBool "BUILD_TESTING" true)
# From some reason this is needed for tests.
(lib.cmakeBool "PYBIND11_NOPYTHON" false)
];
};

postBuild = ''
# build tests
Expand All @@ -75,32 +84,41 @@ buildPythonPackage rec {
'';

nativeCheckInputs = [
catch
numpy
pytestCheckHook
];

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"
# tests that try to parse setuptools stdout
"tests/extra_setuptools/test_setuphelper.py"
];
#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"
# # tests that try to parse setuptools stdout
# "tests/extra_setuptools/test_setuphelper.py"
#];

disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
# expects KeyError, gets RuntimeError
# https://github.com/pybind/pybind11/issues/4243
"test_cross_module_exception_translator"
];
#disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
# # expects KeyError, gets RuntimeError
# # https://github.com/pybind/pybind11/issues/4243
# "test_cross_module_exception_translator"
#];
passthru = {
# scikit-build-core's tests depend upon pybind11, and hence introduce
# infinite recursion. To avoid this, we define here a scikit-build-core
# derivation that doesn't depend on pybind11, and use it for pybind11's
# build-system.
scikit-build-core-no-tests = scikit-build-core.overridePythonAttrs (old: {
doInstallCheck = false;
nativeCheckInputs = [ ];
});
};

hardeningDisable = lib.optional stdenv.hostPlatform.isMusl "fortify";

meta = with lib; {
meta = {
homepage = "https://github.com/pybind/pybind11";
changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst";
description = "Seamless operability between C++11 and Python";
Expand All @@ -110,8 +128,8 @@ buildPythonPackage rec {
C++ types in Python and vice versa, mainly to create Python
bindings of existing C++ code.
'';
license = licenses.bsd3;
maintainers = with maintainers; [
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
yuriaisaka
dotlambda
];
Expand Down
Loading