From fbbe75d6e9737f10cd29d142187d971b87984477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sun, 20 Jun 2021 14:04:46 +0200 Subject: [PATCH] pythonPackages.pybind11: improve expression We shouldn't build and install the package in preFixup. --- .../python-modules/pybind11/default.nix | 41 ++++++++++--------- .../python-modules/scipy/default.nix | 4 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/pkgs/development/python-modules/pybind11/default.nix b/pkgs/development/python-modules/pybind11/default.nix index 3bd88368e75..e852279d23d 100644 --- a/pkgs/development/python-modules/pybind11/default.nix +++ b/pkgs/development/python-modules/pybind11/default.nix @@ -3,12 +3,12 @@ , buildPythonPackage , fetchFromGitHub , fetchpatch -, python -, pytest , cmake +, eigen +, python , catch , numpy -, eigen +, pytest , scipy }: @@ -33,38 +33,41 @@ buildPythonPackage rec { nativeBuildInputs = [ cmake ]; - buildInputs = [ catch ]; + dontUseCmakeBuildDir = true; cmakeFlags = [ "-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3" + "-DBUILD_TESTING=on" ] ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [ - # 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" + "-DPYBIND11_CXX_STANDARD=-std=c++17" ]; - dontUseSetuptoolsBuild = true; - dontUsePipInstall = true; - dontUseSetuptoolsCheck = true; + postBuild = '' + # build tests + make + ''; - preFixup = '' - pushd .. - export PYBIND11_USE_CMAKE=1 - setuptoolsBuildPhase - pipInstallPhase + postInstall = '' # 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 ''; checkInputs = [ - pytest + catch numpy + pytest scipy ]; + checkPhase = '' + runHook preCheck + + make check + + runHook postCheck + ''; + meta = with lib; { homepage = "https://github.com/pybind/pybind11"; description = "Seamless operability between C++11 and Python"; @@ -74,6 +77,6 @@ buildPythonPackage rec { bindings of existing C++ code. ''; license = licenses.bsd3; - maintainers = with maintainers;[ yuriaisaka ]; + maintainers = with maintainers; [ yuriaisaka dotlambda ]; }; } diff --git a/pkgs/development/python-modules/scipy/default.nix b/pkgs/development/python-modules/scipy/default.nix index e118a9f7b6e..0301db2b0b5 100644 --- a/pkgs/development/python-modules/scipy/default.nix +++ b/pkgs/development/python-modules/scipy/default.nix @@ -1,9 +1,9 @@ {lib, fetchPypi, python, buildPythonPackage, gfortran, nose, pytest, numpy, pybind11}: let - pybind = pybind11.overridePythonAttrs(oldAttrs: { + pybind = pybind11.overridePythonAttrs (oldAttrs: { cmakeFlags = oldAttrs.cmakeFlags ++ [ - "-DPYBIND11_TEST=off" + "-DBUILD_TESTING=off" ]; doCheck = false; # Circular test dependency });