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