nixpkgs/pkgs/development/python-modules/pybind11/default.nix
Josef Kemetmüller 084eaa4987 pybind11: Unify with pythonPackages.pybind11
Instead of one derivation providing a cmake-compatible library and one
providing a setuptools-compatible library, we now support both ways of
consuming the library for both pybind11 and python.pkgs.pybind11.
2019-11-28 21:36:58 -08:00

72 lines
1.7 KiB
Nix

{ lib
, buildPythonPackage
, fetchFromGitHub
, fetchpatch
, python
, pytest
, cmake
, catch
, numpy
, eigen
, scipy
}:
buildPythonPackage rec {
pname = "pybind11";
version = "2.4.3";
src = fetchFromGitHub {
owner = "pybind";
repo = pname;
rev = "v${version}";
sha256 = "0k89w4bsfbpzw963ykg1cyszi3h3nk393qd31m6y46pcfxkqh4rd";
};
nativeBuildInputs = [ cmake ];
buildInputs = [ catch ];
cmakeFlags = [
"-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
] ++ lib.optionals (!python.isPy2) [
# Enable some tests only on Python 3. The "test_string_view" test
# 'testTypeError: string_view16_chars(): incompatible function arguments'
# fails on Python 2.
"-DPYBIND11_CPP_STANDARD=-std=c++17"
];
dontUseSetuptoolsBuild = true;
dontUsePipInstall = true;
dontUseSetuptoolsCheck = true;
preFixup = ''
pushd ..
export PYBIND11_USE_CMAKE=1
setuptoolsBuildPhase
pipInstallPhase
# 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
popd
'';
installCheckTarget = "pytest";
doInstallCheck = true;
checkInputs = [
pytest
numpy
scipy
];
meta = {
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.
'';
license = lib.licenses.bsd3;
maintainers = [ lib.maintainers.yuriaisaka ];
};
}