1{ lib 2, stdenv 3, buildPythonPackage 4, pythonOlder 5, fetchFromGitHub 6, cmake 7, cython_3 8, ninja 9, scikit-build 10, setuptools 11, numpy 12, hypothesis 13, pandas 14, pytestCheckHook 15, rapidfuzz-cpp 16, taskflow 17}: 18 19buildPythonPackage rec { 20 pname = "rapidfuzz"; 21 version = "3.4.0"; 22 format = "pyproject"; 23 24 disabled = pythonOlder "3.7"; 25 26 src = fetchFromGitHub { 27 owner = "maxbachmann"; 28 repo = "RapidFuzz"; 29 rev = "refs/tags/v${version}"; 30 hash = "sha256-JgTmhnKVzv9m8//GMQjvCFPNJQM/7dalCD5bk6fWBPc="; 31 }; 32 33 nativeBuildInputs = [ 34 cmake 35 cython_3 36 ninja 37 scikit-build 38 setuptools 39 ]; 40 41 dontUseCmakeConfigure = true; 42 43 buildInputs = [ 44 rapidfuzz-cpp 45 taskflow 46 ]; 47 48 preBuild = '' 49 export RAPIDFUZZ_BUILD_EXTENSION=1 50 '' + lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) '' 51 export CMAKE_ARGS="-DCMAKE_CXX_COMPILER_AR=$AR -DCMAKE_CXX_COMPILER_RANLIB=$RANLIB" 52 ''; 53 54 env.NIX_CFLAGS_COMPILE = toString (lib.optionals (stdenv.cc.isClang && stdenv.isDarwin) [ 55 "-fno-lto" # work around https://github.com/NixOS/nixpkgs/issues/19098 56 ]); 57 58 passthru.optional-dependencies = { 59 full = [ numpy ]; 60 }; 61 62 preCheck = '' 63 export RAPIDFUZZ_IMPLEMENTATION=cpp 64 ''; 65 66 nativeCheckInputs = [ 67 hypothesis 68 pandas 69 pytestCheckHook 70 ]; 71 72 disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ 73 # segfaults 74 "test_cdist" 75 ]; 76 77 pythonImportsCheck = [ 78 "rapidfuzz.distance" 79 "rapidfuzz.fuzz" 80 "rapidfuzz.process" 81 "rapidfuzz.utils" 82 ]; 83 84 meta = with lib; { 85 description = "Rapid fuzzy string matching"; 86 homepage = "https://github.com/maxbachmann/RapidFuzz"; 87 changelog = "https://github.com/maxbachmann/RapidFuzz/blob/${src.rev}/CHANGELOG.rst"; 88 license = licenses.mit; 89 maintainers = with maintainers; [ dotlambda ]; 90 }; 91}