1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 cmake,
7 cython,
8 ninja,
9 scikit-build-core,
10 numpy,
11 hypothesis,
12 pandas,
13 pytestCheckHook,
14 rapidfuzz-cpp,
15 taskflow,
16}:
17
18buildPythonPackage rec {
19 pname = "rapidfuzz";
20 version = "3.14.1";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "maxbachmann";
25 repo = "RapidFuzz";
26 tag = "v${version}";
27 hash = "sha256-p+Z2c+PBNdjfaRjZErWwWgihzuddV14PgTHE3NVNHs8=";
28 };
29
30 build-system = [
31 cmake
32 cython
33 ninja
34 scikit-build-core
35 ];
36
37 dontUseCmakeConfigure = true;
38
39 buildInputs = [
40 rapidfuzz-cpp
41 taskflow
42 ];
43
44 env.RAPIDFUZZ_BUILD_EXTENSION = 1;
45
46 preBuild = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
47 export CMAKE_ARGS="-DCMAKE_CXX_COMPILER_AR=$AR -DCMAKE_CXX_COMPILER_RANLIB=$RANLIB"
48 '';
49
50 optional-dependencies = {
51 all = [ numpy ];
52 };
53
54 preCheck = ''
55 export RAPIDFUZZ_IMPLEMENTATION=cpp
56 '';
57
58 nativeCheckInputs = [
59 hypothesis
60 pandas
61 pytestCheckHook
62 ];
63
64 pythonImportsCheck = [
65 "rapidfuzz.distance"
66 "rapidfuzz.fuzz"
67 "rapidfuzz.process"
68 "rapidfuzz.utils"
69 ];
70
71 meta = {
72 description = "Rapid fuzzy string matching";
73 homepage = "https://github.com/maxbachmann/RapidFuzz";
74 changelog = "https://github.com/maxbachmann/RapidFuzz/blob/${src.tag}/CHANGELOG.rst";
75 license = lib.licenses.mit;
76 maintainers = with lib.maintainers; [ dotlambda ];
77 };
78}