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.
This commit is contained in:
@@ -5,9 +5,10 @@
|
||||
, python
|
||||
, pytest
|
||||
, cmake
|
||||
, numpy ? null
|
||||
, eigen ? null
|
||||
, scipy ? null
|
||||
, catch
|
||||
, numpy
|
||||
, eigen
|
||||
, scipy
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
@@ -21,22 +22,41 @@ buildPythonPackage rec {
|
||||
sha256 = "0k89w4bsfbpzw963ykg1cyszi3h3nk393qd31m6y46pcfxkqh4rd";
|
||||
};
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
checkInputs = [ pytest ]
|
||||
++ (lib.optional (numpy != null) numpy)
|
||||
++ (lib.optional (eigen != null) eigen)
|
||||
++ (lib.optional (scipy != null) scipy);
|
||||
checkPhase = ''
|
||||
cmake ${if eigen != null then "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3" else ""}
|
||||
make -j $NIX_BUILD_CORES pytest
|
||||
|
||||
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
|
||||
'';
|
||||
|
||||
# re-expose the headers to other packages
|
||||
postInstall = ''
|
||||
ln -s $out/include/python${python.pythonVersion}m/pybind11/ $out/include/pybind11
|
||||
'';
|
||||
installCheckTarget = "pytest";
|
||||
doInstallCheck = true;
|
||||
checkInputs = [
|
||||
pytest
|
||||
numpy
|
||||
scipy
|
||||
];
|
||||
|
||||
meta = {
|
||||
homepage = https://github.com/pybind/pybind11;
|
||||
|
||||
Reference in New Issue
Block a user