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:
Josef Kemetmüller 2019-11-26 23:47:23 +01:00 committed by Jon
parent a2e9b7bf12
commit 084eaa4987
4 changed files with 37 additions and 71 deletions

View File

@ -1,47 +0,0 @@
{ stdenv, fetchurl, fetchFromGitHub, cmake, catch, python, eigen }:
stdenv.mkDerivation rec {
pname = "pybind";
version = "2.2.4";
src = fetchFromGitHub {
owner = "pybind";
repo = "pybind11";
rev = "v${version}";
sha256 = "0pa79ymcasv8br5ifbx7878id5py2jpjac3i20cqxr6gs9l6ivlv";
};
nativeBuildInputs = [ cmake ];
checkInputs = with python.pkgs; [ catch eigen pytest numpy scipy ];
# Disable test_cmake_build test, as it fails in sandbox
# https://github.com/pybind/pybind11/issues/1355
patches = [
./no_test_cmake_build.patch
(fetchurl { # Remove on bump to v2.2.5
name = "pytest_namespace_to_configure.patch";
url = "https://github.com/pybind/pybind11/commit/e7ef34f23f194cfa40bdbf967c6d34712261a4ee.patch";
sha256 = "1dhv6p0b5fxzxc8j3sfy8kvfmdshczk22xfxh6bk0cfnfdy9iqrq";
})
];
doCheck = true;
cmakeFlags = [
"-DPYTHON_EXECUTABLE=${python.interpreter}"
"-DPYBIND11_TEST=${if doCheck then "ON" else "OFF"}"
];
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.
'';
platforms = with stdenv.lib.platforms; unix;
license = stdenv.lib.licenses.bsd3;
maintainers = with stdenv.lib.maintainers; [ yuriaisaka ];
};
}

View File

@ -1,7 +0,0 @@
--- a/tests/CMakeLists.txt 2019-01-28 14:13:55.822119328 +0100
+++ b/tests/CMakeLists.txt 2019-01-28 14:14:06.741161928 +0100
@@ -233,4 +233,3 @@
add_subdirectory(test_embed)
# Test CMake build using functions and targets from subdirectory or installed location
-add_subdirectory(test_cmake_build)

View File

@ -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;

View File

@ -13531,7 +13531,7 @@ in
pugixml = callPackage ../development/libraries/pugixml { };
pybind11 = callPackage ../development/libraries/pybind11 { };
pybind11 = pythonPackages.pybind11;
python-qt = callPackage ../development/libraries/python-qt {
python = python27;