1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 distutils,
6 setuptools,
7 unicorn-angr,
8}:
9
10buildPythonPackage rec {
11 pname = "unicorn-angr";
12 version = lib.getVersion unicorn-angr;
13 pyproject = true;
14
15 src = unicorn-angr.src;
16
17 sourceRoot = "${src.name}/bindings/python";
18
19 prePatch = ''
20 ln -s ${unicorn-angr}/lib/libunicorn.* prebuilt/
21 '';
22
23 # Needed on non-x86 linux
24 setupPyBuildFlags =
25 lib.optionals stdenv.hostPlatform.isLinux [
26 "--plat-name"
27 "linux"
28 ]
29 # aarch64 only available from MacOS SDK 11 onwards, so fix the version tag.
30 # otherwise, bdist_wheel may detect "macosx_10_6_arm64" which doesn't make sense.
31 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
32 "--plat-name"
33 "macosx_11_0"
34 ];
35
36 build-system = [
37 distutils
38 setuptools
39 ];
40
41 checkPhase = ''
42 runHook preCheck
43
44 mv unicorn unicorn.hidden
45 patchShebangs sample_*.py shellcode.py
46 sh -e sample_all.sh
47
48 runHook postCheck
49 '';
50
51 pythonImportsCheck = [ "unicorn" ];
52
53 meta = with lib; {
54 description = "Python bindings for Unicorn CPU emulator engine";
55 homepage = "https://www.unicorn-engine.org/";
56 license = licenses.gpl2Plus;
57 maintainers = with maintainers; [ fab ];
58 };
59}