about summary refs log tree commit diff
path: root/pkgs/development/python-modules/levenshtein/default.nix
blob: a7913fd5b097086921118e4e8976ee517a90879f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
  lib,
  stdenv,
  buildPythonPackage,
  cmake,
  cython,
  fetchFromGitHub,
  pytestCheckHook,
  pythonOlder,
  rapidfuzz,
  rapidfuzz-cpp,
  scikit-build,
}:

buildPythonPackage rec {
  pname = "levenshtein";
  version = "0.25.1";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "maxbachmann";
    repo = "Levenshtein";
    rev = "refs/tags/v${version}";
    hash = "sha256-ye2XQL/ZQPlA4dy3tlr03WyGhfl7SaOXMt10cWHnW5o=";
    fetchSubmodules = true; # # for vendored `rapidfuzz-cpp`
  };

  nativeBuildInputs = [
    cmake
    cython
    scikit-build
  ];

  dontUseCmakeConfigure = true;

  buildInputs = [ rapidfuzz-cpp ];

  env.NIX_CFLAGS_COMPILE = toString (
    lib.optionals (stdenv.cc.isClang && stdenv.isDarwin) [
      "-fno-lto" # work around https://github.com/NixOS/nixpkgs/issues/19098
    ]
  );

  dependencies = [ rapidfuzz ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "Levenshtein" ];

  meta = with lib; {
    description = "Functions for fast computation of Levenshtein distance and string similarity";
    homepage = "https://github.com/maxbachmann/Levenshtein";
    changelog = "https://github.com/maxbachmann/Levenshtein/blob/${src.rev}/HISTORY.md";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ fab ];
  };
}