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