2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
capstone,
|
|
|
|
stdenv,
|
|
|
|
setuptools,
|
2024-07-27 06:49:29 +00:00
|
|
|
fetchpatch,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "capstone";
|
2021-02-05 17:12:51 +00:00
|
|
|
version = lib.getVersion capstone;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = capstone.src;
|
2023-08-04 22:07:22 +00:00
|
|
|
sourceRoot = "${src.name}/bindings/python";
|
2024-07-27 06:49:29 +00:00
|
|
|
patches = [
|
|
|
|
# Drop distutils in python binding (PR 2271)
|
|
|
|
(fetchpatch {
|
|
|
|
name = "drop-distutils-in-python-binding.patch";
|
|
|
|
url = "https://github.com/capstone-engine/capstone/commit/d63211e3acb64fceb8b1c4a0d804b4b027f4ef71.patch";
|
|
|
|
hash = "sha256-zUGeFmm3xH5dzfPJE8nnHwqwFBrsZ7w8LBJAy20/3RI=";
|
|
|
|
stripLen = 2;
|
|
|
|
})
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# libcapstone.a is not built with BUILD_SHARED_LIBS. For some reason setup.py
|
|
|
|
# checks if it exists but it is not really needed. Most likely a bug in setup.py.
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
|
|
|
ln -s ${capstone}/lib/libcapstone${stdenv.targetPlatform.extensions.sharedLibrary} prebuilt/
|
2024-04-21 15:54:59 +00:00
|
|
|
touch prebuilt/libcapstone${stdenv.targetPlatform.extensions.staticLibrary}
|
2021-02-16 17:04:54 +00:00
|
|
|
substituteInPlace setup.py --replace manylinux1 manylinux2014
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
# aarch64 only available from MacOS SDK 11 onwards, so fix the version tag.
|
|
|
|
# otherwise, bdist_wheel may detect "macosx_10_6_arm64" which doesn't make sense.
|
2024-06-05 15:53:02 +00:00
|
|
|
setupPyBuildFlags = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
|
|
"--plat-name"
|
|
|
|
"macosx_11_0"
|
|
|
|
];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [ setuptools ];
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
mv capstone capstone.hidden
|
|
|
|
patchShebangs test_*
|
|
|
|
make check
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://www.capstone-engine.org/";
|
|
|
|
license = licenses.bsdOriginal;
|
|
|
|
description = "Python bindings for Capstone disassembly engine";
|
2024-06-05 15:53:02 +00:00
|
|
|
maintainers = with maintainers; [
|
|
|
|
bennofs
|
|
|
|
ris
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|