1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cmake,
6 cython,
7 fetchFromGitHub,
8 pytestCheckHook,
9 pythonOlder,
10 rapidfuzz,
11 rapidfuzz-cpp,
12 scikit-build,
13}:
14
15buildPythonPackage rec {
16 pname = "levenshtein";
17 version = "0.25.1";
18 pyproject = true;
19
20 disabled = pythonOlder "3.8";
21
22 src = fetchFromGitHub {
23 owner = "maxbachmann";
24 repo = "Levenshtein";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-ye2XQL/ZQPlA4dy3tlr03WyGhfl7SaOXMt10cWHnW5o=";
27 fetchSubmodules = true; # # for vendored `rapidfuzz-cpp`
28 };
29
30 nativeBuildInputs = [
31 cmake
32 cython
33 scikit-build
34 ];
35
36 dontUseCmakeConfigure = true;
37
38 buildInputs = [ rapidfuzz-cpp ];
39
40 env.NIX_CFLAGS_COMPILE = toString (
41 lib.optionals (stdenv.cc.isClang && stdenv.isDarwin) [
42 "-fno-lto" # work around https://github.com/NixOS/nixpkgs/issues/19098
43 ]
44 );
45
46 dependencies = [ rapidfuzz ];
47
48 nativeCheckInputs = [ pytestCheckHook ];
49
50 pythonImportsCheck = [ "Levenshtein" ];
51
52 meta = with lib; {
53 description = "Functions for fast computation of Levenshtein distance and string similarity";
54 homepage = "https://github.com/maxbachmann/Levenshtein";
55 changelog = "https://github.com/maxbachmann/Levenshtein/blob/${src.rev}/HISTORY.md";
56 license = licenses.gpl2Plus;
57 maintainers = with maintainers; [ fab ];
58 };
59}