summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/unicorn/default.nix
blob: 661a9faa420cf1f81d8cbfa0659ba7485b2ac0ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
  lib,
  stdenv,
  buildPythonPackage,
  capstone,
  pytestCheckHook,
  setuptools-scm,
  setuptools,
  unicorn,
}:

buildPythonPackage rec {
  pname = "unicorn";
  version = lib.getVersion unicorn;
  pyproject = true;

  src = unicorn.src;

  sourceRoot = "${src.name}/bindings/python";

  prePatch = ''
    ln -s ${unicorn}/lib/libunicorn.* prebuilt/
  '';

  # Needed on non-x86 linux
  setupPyBuildFlags =
    lib.optionals stdenv.hostPlatform.isLinux [
      "--plat-name"
      "linux"
    ]
    # 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.
    ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
      "--plat-name"
      "macosx_11_0"
    ];

  build-system = [
    setuptools
    setuptools-scm
  ];

  nativeCheckInputs = [
    capstone
    pytestCheckHook
  ];

  # this test does not appear to be intended as a pytest-style test
  disabledTests = [ "test_i386" ];

  pythonImportsCheck = [ "unicorn" ];

  meta = {
    description = "Python bindings for Unicorn CPU emulator engine";
    homepage = "https://www.unicorn-engine.org/";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [
      bennofs
      ris
    ];
  };
}