1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchPypi,
6 rustPlatform,
7 pytestCheckHook,
8 pyahocorasick,
9 hypothesis,
10 typing-extensions,
11 pytest-benchmark,
12}:
13
14buildPythonPackage rec {
15 pname = "ahocorasick-rs";
16 version = "0.22.0";
17
18 pyproject = true;
19
20 src = fetchPypi {
21 inherit version;
22 pname = "ahocorasick_rs";
23 hash = "sha256-lzRwODlJlymMSih3CqNIeR+HrUbgVhroM1JuHFfW848=";
24 };
25
26 cargoDeps = rustPlatform.fetchCargoTarball {
27 inherit src;
28 name = "${pname}-${version}";
29 hash = "sha256-CIt/ChNcoqKln6PgeTGp9pfmIWlJj+c5SCPtBhsnT6U=";
30 };
31
32 nativeBuildInputs = with rustPlatform; [
33 maturinBuildHook
34 cargoSetupHook
35 ];
36
37 dependencies = lib.optionals (pythonOlder "3.12") [ typing-extensions ];
38
39 nativeCheckInputs = [
40 pytest-benchmark
41 pytestCheckHook
42 pyahocorasick
43 hypothesis
44 ];
45
46 pythonImportsCheck = [ "ahocorasick_rs" ];
47
48 meta = with lib; {
49 description = "Fast Aho-Corasick algorithm for Python";
50 homepage = "https://github.com/G-Research/ahocorasick_rs/";
51 changelog = "https://github.com/G-Research/ahocorasick_rs/blob/${version}/CHANGELOG.md";
52 license = licenses.asl20;
53 maintainers = with maintainers; [ erictapen ];
54 };
55
56}