2021-04-25 03:57:28 +00:00
|
|
|
{ lib
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
2021-02-16 17:04:54 +00:00
|
|
|
, capstone
|
2021-04-25 03:57:28 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, setuptools
|
2024-04-21 15:54:59 +00:00
|
|
|
, pythonAtLeast
|
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-01-02 11:29:13 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# distutils usage
|
|
|
|
disabled = pythonAtLeast "3.12";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = capstone.src;
|
2023-08-04 22:07:22 +00:00
|
|
|
sourceRoot = "${src.name}/bindings/python";
|
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.
|
|
|
|
setupPyBuildFlags = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ "--plat-name" "macosx_11_0" ];
|
|
|
|
|
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";
|
|
|
|
maintainers = with maintainers; [ bennofs ris ];
|
|
|
|
};
|
|
|
|
}
|