summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyoprf/default.nix
blob: ca3e61692cee8b6bde8cecb5b10d6a820f60264c (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
63
64
65
{
  lib,
  stdenv,
  buildPythonPackage,
  liboprf,
  setuptools,
  ble-serial,
  pyserial,
  pyserial-asyncio,
  pysodium,
  pyudev,
  securestring,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "pyoprf";
  pyproject = true;

  inherit (liboprf)
    version
    src
    ;

  postPatch =
    let
      soext = stdenv.hostPlatform.extensions.sharedLibrary;
    in
    ''
      substituteInPlace ./pyoprf/__init__.py --replace-fail \
        "ctypes.util.find_library('oprf') or ctypes.util.find_library('liboprf')" "'${lib.getLib liboprf}/lib/liboprf${soext}'"
      substituteInPlace pyoprf/noisexk.py \
        --replace-fail "ctypes.util.find_library('oprf-noiseXK')" "'${lib.getLib liboprf}/lib/liboprf-noiseXK${soext}'" \
        --replace-fail "or ctypes.util.find_library('liboprf-noiseXK')" ""
    '';

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

  build-system = [ setuptools ];

  dependencies = [
    ble-serial
    pyserial
    pyserial-asyncio
    pysodium
    pyudev
    securestring
  ];

  pythonImportsCheck = [ "pyoprf" ];

  nativeCheckInputs = [ pytestCheckHook ];

  pytestFlagsArray = [ "tests/test.py" ];

  meta = {
    homepage = "https://github.com/stef/liboprf/tree/master/python";
    inherit (liboprf.meta)
      description
      changelog
      license
      teams
      ;
  };
}