1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 pytestCheckHook,
7 pythonOlder,
8 yara,
9}:
10
11buildPythonPackage rec {
12 pname = "yara-python";
13 version = "4.5.4";
14 pyproject = true;
15
16 disabled = pythonOlder "3.7";
17
18 src = fetchFromGitHub {
19 owner = "VirusTotal";
20 repo = "yara-python";
21 tag = "v${version}";
22 hash = "sha256-2ZwLpkT46KNTQ1ymvMGjnrfHQaIy/rXid0kXoCBixXA=";
23 };
24
25 # undefined symbol: yr_finalize
26 # https://github.com/VirusTotal/yara-python/issues/7
27 postPatch = ''
28 substituteInPlace setup.py \
29 --replace-fail "include_dirs=['yara/libyara/include', 'yara/libyara/', '.']" "libraries = ['yara']"
30 '';
31
32 build-system = [ setuptools ];
33
34 buildInputs = [ yara ];
35
36 nativeCheckInputs = [ pytestCheckHook ];
37
38 setupPyBuildFlags = [ "--dynamic-linking" ];
39
40 enabledTestPaths = [ "tests.py" ];
41
42 pythonImportsCheck = [ "yara" ];
43
44 meta = with lib; {
45 description = "Python interface for YARA";
46 homepage = "https://github.com/VirusTotal/yara-python";
47 changelog = "https://github.com/VirusTotal/yara-python/releases/tag/v${version}";
48 license = licenses.asl20;
49 maintainers = with maintainers; [ fab ];
50 };
51}