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