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