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${stdenv.targetPlatform.extensions.sharedLibrary} prebuilt/
19 ln -s ${unicorn-emu}/lib/libunicorn.a prebuilt/
20 '';
21
22 # needed on non-x86 linux
23 setupPyBuildFlags = lib.optionals stdenv.isLinux [ "--plat-name" "linux" ];
24
25 propagatedBuildInputs = [
26 setuptools
27 ];
28
29 checkPhase = ''
30 runHook preCheck
31
32 mv unicorn unicorn.hidden
33 patchShebangs sample_*.py shellcode.py
34 sh -e sample_all.sh
35
36 runHook postCheck
37 '';
38
39 pythonImportsCheck = [
40 "unicorn"
41 ];
42
43 meta = with lib; {
44 description = "Python bindings for Unicorn CPU emulator engine";
45 homepage = "https://www.unicorn-engine.org/";
46 license = licenses.gpl2Plus;
47 maintainers = with maintainers; [ bennofs ris ];
48 };
49}