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