1{ 2 lib, 3 buildPythonPackage, 4 capstone_4, 5 stdenv, 6 setuptools, 7 fetchpatch, 8}: 9 10buildPythonPackage { 11 format = "setuptools"; 12 pname = "capstone"; 13 inherit (capstone_4) version src; 14 15 sourceRoot = "${capstone_4.src.name}/bindings/python"; 16 patches = [ 17 # Drop distutils in python binding (PR 2271) 18 (fetchpatch { 19 name = "drop-distutils-in-python-binding.patch"; 20 url = "https://github.com/capstone-engine/capstone/commit/d63211e3acb64fceb8b1c4a0d804b4b027f4ef71.patch"; 21 hash = "sha256-zUGeFmm3xH5dzfPJE8nnHwqwFBrsZ7w8LBJAy20/3RI="; 22 stripLen = 2; 23 }) 24 ]; 25 26 postPatch = '' 27 ln -s ${capstone_4}/lib/libcapstone${stdenv.targetPlatform.extensions.sharedLibrary} prebuilt/ 28 ln -s ${capstone_4}/lib/libcapstone${stdenv.targetPlatform.extensions.staticLibrary} prebuilt/ 29 substituteInPlace setup.py --replace manylinux1 manylinux2014 30 ''; 31 32 # aarch64 only available from MacOS SDK 11 onwards, so fix the version tag. 33 # otherwise, bdist_wheel may detect "macosx_10_6_arm64" which doesn't make sense. 34 setupPyBuildFlags = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 35 "--plat-name" 36 "macosx_11_0" 37 ]; 38 39 propagatedBuildInputs = [ setuptools ]; 40 41 checkPhase = '' 42 mv capstone capstone.hidden 43 patchShebangs test_* 44 make check 45 ''; 46 47 meta = with lib; { 48 homepage = "http://www.capstone-engine.org/"; 49 license = licenses.bsdOriginal; 50 description = "Python bindings for Capstone disassembly engine"; 51 maintainers = with maintainers; [ 52 bennofs 53 ris 54 ]; 55 }; 56}