1{
2 lib,
3 archinfo,
4 buildPythonPackage,
5 cart,
6 cffi,
7 fetchFromGitHub,
8 pefile,
9 pyelftools,
10 pytestCheckHook,
11 pythonOlder,
12 pyvex,
13 setuptools,
14 sortedcontainers,
15}:
16
17let
18 # The binaries are following the argr projects release cycle
19 version = "9.2.133";
20
21 # Binary files from https://github.com/angr/binaries (only used for testing and only here)
22 binaries = fetchFromGitHub {
23 owner = "angr";
24 repo = "binaries";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-+vAD9XvqV45wf7sf+VuhTbw2gFeJra5gBptfg8r8e8U=";
27 };
28in
29buildPythonPackage rec {
30 pname = "cle";
31 inherit version;
32 pyproject = true;
33
34 disabled = pythonOlder "3.11";
35
36 src = fetchFromGitHub {
37 owner = "angr";
38 repo = "cle";
39 rev = "refs/tags/v${version}";
40 hash = "sha256-R57Qd04/xtDW7/WDcZpOhkYOBCSmBNq2Bn3BYDfjseA=";
41 };
42
43 build-system = [ setuptools ];
44
45 dependencies = [
46 archinfo
47 cart
48 cffi
49 pefile
50 pyelftools
51 pyvex
52 sortedcontainers
53 ];
54
55 nativeCheckInputs = [ pytestCheckHook ];
56
57 # Place test binaries in the right location (location is hard-coded in the tests)
58 preCheck = ''
59 export HOME=$TMPDIR
60 cp -r ${binaries} $HOME/binaries
61 '';
62
63 disabledTests = [
64 # PPC tests seems to fails
65 "test_ppc_rel24_relocation"
66 "test_ppc_addr16_ha_relocation"
67 "test_ppc_addr16_lo_relocation"
68 "test_plt_full_relro"
69 # Test fails
70 "test_tls_pe_incorrect_tls_data_start"
71 "test_x86"
72 "test_x86_64"
73 # The required parts is not present on Nix
74 "test_remote_file_map"
75 ];
76
77 pythonImportsCheck = [ "cle" ];
78
79 meta = with lib; {
80 description = "Python loader for many binary formats";
81 homepage = "https://github.com/angr/cle";
82 license = with licenses; [ bsd2 ];
83 maintainers = with maintainers; [ fab ];
84 };
85}