1{
2 lib,
3 pkgs,
4 buildPythonPackage,
5 fetchFromGitHub,
6 symlinkJoin,
7 cmake,
8 ninja,
9 pathspec,
10 pcre,
11 scikit-build-core,
12 pytestCheckHook,
13 pytest-mock,
14}:
15let
16 lib-deps = symlinkJoin {
17 name = "hyperscan-static-deps";
18 paths = [
19 (pkgs.hyperscan.override { withStatic = true; })
20 (pcre.overrideAttrs { dontDisableStatic = 0; }).out
21 ];
22 };
23in
24buildPythonPackage rec {
25 pname = "hyperscan";
26 version = "0.7.25";
27 pyproject = true;
28
29 src = fetchFromGitHub {
30 owner = "darvid";
31 repo = "python-hyperscan";
32 tag = "v${version}";
33 hash = "sha256-YFT/SPAI/H6D7paWL/9rMyvY1s7ffE9bDHcQ9TbbA6w=";
34 };
35
36 env.CMAKE_ARGS = "-DHS_SRC_ROOT=${pkgs.hyperscan.src} -DHS_BUILD_LIB_ROOT=${lib-deps}/lib";
37
38 dontUseCmakeConfigure = true;
39
40 nativeBuildInputs = [
41 cmake
42 pathspec
43 ninja
44 scikit-build-core
45 ];
46
47 pythonImportsCheck = [ "hyperscan" ];
48
49 enabledTestPaths = [ "tests" ];
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 pytest-mock
54 ];
55
56 meta = with lib; {
57 description = "CPython extension for the Hyperscan regular expression matching library";
58 homepage = "https://github.com/darvid/python-hyperscan";
59 changelog = "https://github.com/darvid/python-hyperscan/blob/${src.tag}/CHANGELOG.md";
60 platforms = [
61 "x86_64-linux"
62 "x86_64-darwin"
63 ];
64 license = licenses.mit;
65 maintainers = with maintainers; [ mbalatsko ];
66 };
67}