diff options
author | Josef Kemetmüller <josef.kemetmueller@gmail.com> | 2019-11-26 23:47:23 +0100 |
---|---|---|
committer | Jon <jonringer@users.noreply.github.com> | 2019-11-28 21:36:58 -0800 |
commit | 084eaa498727f676e864b2b0ff504f3a74f09c98 (patch) | |
tree | 917bbb1e2c7e108b6bcb20deed9268dea72990ee /pkgs/development/python-modules/pybind11 | |
parent | a2e9b7bf12c90bfaeda7f9a5e81c7de74bf711c7 (diff) | |
download | nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.tar nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.tar.gz nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.tar.bz2 nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.tar.lz nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.tar.xz nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.tar.zst nixpkgs-084eaa498727f676e864b2b0ff504f3a74f09c98.zip |
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.
Diffstat (limited to 'pkgs/development/python-modules/pybind11')
-rw-r--r-- | pkgs/development/python-modules/pybind11/default.nix | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/pkgs/development/python-modules/pybind11/default.nix b/pkgs/development/python-modules/pybind11/default.nix index 2df360dfaab..0f386a7c42f 100644 --- a/pkgs/development/python-modules/pybind11/default.nix +++ b/pkgs/development/python-modules/pybind11/default.nix @@ -5,9 +5,10 @@ , python , pytest , cmake -, numpy ? null -, eigen ? null -, scipy ? null +, catch +, numpy +, eigen +, scipy }: buildPythonPackage rec { @@ -21,23 +22,42 @@ 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 - ''; - # re-expose the headers to other packages - postInstall = '' - ln -s $out/include/python${python.pythonVersion}m/pybind11/ $out/include/pybind11 + 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"; |