1{ lib
2, stdenv
3, fetchFromGitHub
4, buildPythonPackage
5, rustPlatform
6, pytestCheckHook
7, libiconv
8, vectorscan
9}:
10
11buildPythonPackage rec {
12 pname = "pyperscan";
13 version = "0.2.2";
14 format = "pyproject";
15
16 src = fetchFromGitHub {
17 owner = "vlaci";
18 repo = "pyperscan";
19 rev = "v${version}";
20 hash = "sha256-ioNGEmWy+lEzazF1RzMFS06jYLNYll3QSlWAF0AoU7Y=";
21 };
22
23 cargoDeps = rustPlatform.fetchCargoTarball {
24 inherit src;
25 name = "${pname}-${version}";
26 hash = "sha256-2zppyxJ+XaI/JCkp7s27/jgtSbwxnI4Yil5KT8WgrVI=";
27 };
28
29 nativeBuildInputs = with rustPlatform; [
30 bindgenHook
31 cargoSetupHook
32 maturinBuildHook
33 ];
34
35 checkInputs = [ pytestCheckHook ];
36
37 buildInputs = [ vectorscan ] ++ lib.optional stdenv.isDarwin libiconv;
38
39 # Disable default features to use the system vectorscan library instead of a vendored one.
40 maturinBuildFlags = [ "--no-default-features" ];
41
42 pythonImportsCheck = [ "pyperscan" ];
43
44 meta = with lib; {
45 description = "a hyperscan binding for Python, which supports vectorscan";
46 homepage = "https://github.com/vlaci/pyperscan";
47 platforms = platforms.unix;
48 license = with licenses; [ asl20 /* or */ mit ];
49 maintainers = with maintainers; [ tnias vlaci ];
50 };
51}