Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at master 3.0 kB view raw
1{ 2 stdenv, 3 lib, 4 buildPythonPackage, 5 fetchFromGitHub, 6 cmake, 7 ninja, 8 scikit-build-core, 9 pybind11, 10 boost, 11 eigen, 12 python, 13 catch2, 14 numpy, 15 pytest, 16 makeSetupHook, 17}: 18let 19 setupHook = makeSetupHook { 20 name = "pybind11-setup-hook"; 21 substitutions = { 22 out = placeholder "out"; 23 pythonInterpreter = python.pythonOnBuildForHost.interpreter; 24 pythonIncludeDir = "${python}/include/${python.libPrefix}"; 25 pythonSitePackages = "${python}/${python.sitePackages}"; 26 }; 27 } ./setup-hook.sh; 28in 29buildPythonPackage rec { 30 pname = "pybind11"; 31 version = "3.0.1"; 32 pyproject = true; 33 34 src = fetchFromGitHub { 35 owner = "pybind"; 36 repo = "pybind11"; 37 tag = "v${version}"; 38 hash = "sha256-ZiwNGsE1FOkhnWv/1ib1akhQ4FZvrXRCDnnBZoPp6r4="; 39 }; 40 41 build-system = [ 42 cmake 43 ninja 44 pybind11.passthru.scikit-build-core-no-tests 45 ]; 46 47 buildInputs = [ 48 # Used only for building tests - something we do even when cross 49 # compiling. 50 catch2 51 boost 52 eigen 53 ]; 54 55 propagatedNativeBuildInputs = [ setupHook ]; 56 57 nativeCheckInputs = [ 58 numpy 59 pytest 60 ]; 61 62 pypaBuildFlags = [ 63 # Keep the build directory around to run the tests. 64 "-Cbuild-dir=build" 65 ]; 66 67 cmakeFlags = [ 68 # Always build tests, because even when cross compiling building the tests 69 # is another confirmation that everything is OK. 70 (lib.cmakeBool "BUILD_TESTING" true) 71 72 # Override the `PYBIND11_NOPYTHON = true` in `pyproject.toml`. This 73 # is required to build the tests. 74 (lib.cmakeBool "PYBIND11_NOPYTHON" false) 75 ]; 76 77 dontUseCmakeConfigure = true; 78 79 ninjaFlags = [ 80 "-C" 81 "build" 82 ]; 83 84 checkTarget = "check"; 85 86 checkPhase = "ninjaCheckPhase"; 87 88 # Make the headers and CMake/pkg-config files inside the wheel 89 # discoverable. This simulates the effect of the `pybind11[global]` 90 # installation but works better for our build. 91 postInstall = '' 92 ln -s $out/${python.sitePackages}/pybind11/{include,share} $out/ 93 ''; 94 95 passthru = { 96 # scikit-build-core's tests depend upon pybind11, and hence introduce 97 # infinite recursion. To avoid this, we define here a scikit-build-core 98 # derivation that doesn't depend on pybind11, and use it for pybind11's 99 # build-system. 100 scikit-build-core-no-tests = scikit-build-core.overridePythonAttrs { 101 doCheck = false; 102 }; 103 }; 104 105 hardeningDisable = lib.optional stdenv.hostPlatform.isMusl "fortify"; 106 107 meta = { 108 homepage = "https://github.com/pybind/pybind11"; 109 changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst"; 110 description = "Seamless operability between C++11 and Python"; 111 mainProgram = "pybind11-config"; 112 longDescription = '' 113 Pybind11 is a lightweight header-only library that exposes 114 C++ types in Python and vice versa, mainly to create Python 115 bindings of existing C++ code. 116 ''; 117 license = lib.licenses.bsd3; 118 maintainers = with lib.maintainers; [ 119 yuriaisaka 120 dotlambda 121 ]; 122 }; 123}