1{ 2 lib, 3 buildPythonPackage, 4 capstone, 5 stdenv, 6 setuptools, 7}: 8 9buildPythonPackage rec { 10 pname = "capstone"; 11 version = lib.getVersion capstone; 12 13 src = capstone.src; 14 sourceRoot = "${src.name}/bindings/python"; 15 16 # libcapstone.a is not built with BUILD_SHARED_LIBS. For some reason setup.py 17 # checks if it exists but it is not really needed. Most likely a bug in setup.py. 18 postPatch = '' 19 ln -s ${capstone}/lib/libcapstone${stdenv.targetPlatform.extensions.sharedLibrary} prebuilt/ 20 touch prebuilt/libcapstone${stdenv.targetPlatform.extensions.staticLibrary} 21 substituteInPlace setup.py --replace manylinux1 manylinux2014 22 ''; 23 24 # aarch64 only available from MacOS SDK 11 onwards, so fix the version tag. 25 # otherwise, bdist_wheel may detect "macosx_10_6_arm64" which doesn't make sense. 26 setupPyBuildFlags = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 27 "--plat-name" 28 "macosx_11_0" 29 ]; 30 31 propagatedBuildInputs = [ setuptools ]; 32 33 checkPhase = '' 34 mv capstone capstone.hidden 35 pushd tests 36 patchShebangs test_* 37 make -f ../Makefile check 38 popd 39 ''; 40 41 meta = with lib; { 42 homepage = "http://www.capstone-engine.org/"; 43 license = licenses.bsdOriginal; 44 description = "Python bindings for Capstone disassembly engine"; 45 maintainers = with maintainers; [ 46 bennofs 47 ris 48 ]; 49 }; 50}