git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit084eaa498727f676e864b2b0ff504f3a74f09c98 authorJosef Kemetmüller <josef.kemetmueller@gmail.com> dateTue 26 Nov 2019, 23:47 (7 years ago) parenta2e9b7b
4 files changed+37−71
pkgs/development/libraries/pybind11/default.nix−47 pkgs/development/libraries/pybind11/no_test_cmake_build.patch−7 pkgs/development/python-modules/pybind11/default.nix+36−16 pkgs/top-level/all-packages.nix+1−1
pkgs/development/libraries/pybind11/default.nixdeleted−47
@@ -1,47 +0,0 @@
1−{ stdenv, fetchurl, fetchFromGitHub, cmake, catch, python, eigen }:
2−
3−stdenv.mkDerivation rec {
4− pname = "pybind";
5− version = "2.2.4";
6−
7− src = fetchFromGitHub {
8− owner = "pybind";
9− repo = "pybind11";
10− rev = "v${version}";
11− sha256 = "0pa79ymcasv8br5ifbx7878id5py2jpjac3i20cqxr6gs9l6ivlv";
12− };
13−
14− nativeBuildInputs = [ cmake ];
15− checkInputs = with python.pkgs; [ catch eigen pytest numpy scipy ];
16−
17− # Disable test_cmake_build test, as it fails in sandbox
18− # https://github.com/pybind/pybind11/issues/1355
19− patches = [
20− ./no_test_cmake_build.patch
21− (fetchurl { # Remove on bump to v2.2.5
22− name = "pytest_namespace_to_configure.patch";
23− url = "https://github.com/pybind/pybind11/commit/e7ef34f23f194cfa40bdbf967c6d34712261a4ee.patch";
24− sha256 = "1dhv6p0b5fxzxc8j3sfy8kvfmdshczk22xfxh6bk0cfnfdy9iqrq";
25− })
26− ];
27−
28− doCheck = true;
29−
30− cmakeFlags = [
31− "-DPYTHON_EXECUTABLE=${python.interpreter}"
32− "-DPYBIND11_TEST=${if doCheck then "ON" else "OFF"}"
33− ];
34−
35− meta = {
36− homepage = https://github.com/pybind/pybind11;
37− description = "Seamless operability between C++11 and Python";
38− longDescription = ''
39− Pybind11 is a lightweight header-only library that exposes
40− C++ types in Python and vice versa, mainly to create Python
41− bindings of existing C++ code.
42− '';
43− platforms = with stdenv.lib.platforms; unix;
44− license = stdenv.lib.licenses.bsd3;
45− maintainers = with stdenv.lib.maintainers; [ yuriaisaka ];
46− };
47−}
pkgs/development/libraries/pybind11/no_test_cmake_build.patchdeleted−7
@@ -1,7 +0,0 @@
1−--- a/tests/CMakeLists.txt 2019-01-28 14:13:55.822119328 +0100
2−+++ b/tests/CMakeLists.txt 2019-01-28 14:14:06.741161928 +0100
3−@@ -233,4 +233,3 @@
4− add_subdirectory(test_embed)
5−
6− # Test CMake build using functions and targets from subdirectory or installed location
7−-add_subdirectory(test_cmake_build)
pkgs/development/python-modules/pybind11/default.nix+36−16
@@ -5,9 +5,10 @@
55, python
66, pytest
77, cmake
8−, numpy ? null
9−, eigen ? null
10−, scipy ? null
8+, catch
9+, numpy
10+, eigen
11+, scipy
1112}:
1213
1314buildPythonPackage rec {
@@ -21,23 +22,42 @@ buildPythonPackage rec {
2122 sha256 = "0k89w4bsfbpzw963ykg1cyszi3h3nk393qd31m6y46pcfxkqh4rd";
2223 };
2324
24− dontUseCmakeConfigure = true;
25−
2625 nativeBuildInputs = [ cmake ];
27− checkInputs = [ pytest ]
28− ++ (lib.optional (numpy != null) numpy)
29− ++ (lib.optional (eigen != null) eigen)
30− ++ (lib.optional (scipy != null) scipy);
31− checkPhase = ''
32− cmake ${if eigen != null then "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3" else ""}
33− make -j $NIX_BUILD_CORES pytest
34− '';
3526
36− # re-expose the headers to other packages
37− postInstall = ''
38− ln -s $out/include/python${python.pythonVersion}m/pybind11/ $out/include/pybind11
27+ buildInputs = [ catch ];
28+
29+ cmakeFlags = [
30+ "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
31+ ] ++ lib.optionals (!python.isPy2) [
32+ # Enable some tests only on Python 3. The "test_string_view" test
33+ # 'testTypeError: string_view16_chars(): incompatible function arguments'
34+ # fails on Python 2.
35+ "-DPYBIND11_CPP_STANDARD=-std=c++17"
36+ ];
37+
38+ dontUseSetuptoolsBuild = true;
39+ dontUsePipInstall = true;
40+ dontUseSetuptoolsCheck = true;
41+
42+ preFixup = ''
43+ pushd ..
44+ export PYBIND11_USE_CMAKE=1
45+ setuptoolsBuildPhase
46+ pipInstallPhase
47+ # Symlink the CMake-installed headers to the location expected by setuptools
48+ mkdir -p $out/include/${python.libPrefix}
49+ ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11
50+ popd
3951 '';
4052
53+ installCheckTarget = "pytest";
54+ doInstallCheck = true;
55+ checkInputs = [
56+ pytest
57+ numpy
58+ scipy
59+ ];
60+
4161 meta = {
4262 homepage = https://github.com/pybind/pybind11;
4363 description = "Seamless operability between C++11 and Python";
pkgs/top-level/all-packages.nix+1−1
@@ -13531,7 +13531,7 @@ in
1353113531
1353213532 pugixml = callPackage ../development/libraries/pugixml { };
1353313533
13534− pybind11 = callPackage ../development/libraries/pybind11 { };
13534+ pybind11 = pythonPackages.pybind11;
1353513535
1353613536 python-qt = callPackage ../development/libraries/python-qt {
1353713537 python = python27;