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