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