about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyreqwest-impersonate/default.nix
blob: 465615b99ed8a5ba140790e4a04c72a40b6cb29a (plain) (blame)
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
66
67
68
69
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  rustPlatform,
  pytest,
  runCommand,
  boringssl,
  libiconv,
  SystemConfiguration,
}:

let
  # boring-sys expects the static libraries in build/ instead of lib/
  boringssl-wrapper = runCommand "boringssl-wrapper" { } ''
    mkdir $out
    cd $out
    ln -s ${boringssl.out}/lib build
    ln -s ${boringssl.dev}/include include
  '';
in
buildPythonPackage rec {
  pname = "pyreqwest-impersonate";
  version = "0.4.9";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "deedy5";
    repo = "pyreqwest_impersonate";
    rev = "v${version}";
    hash = "sha256-U22NNYN8p3IQIAVb6dOrErFvuJ5m5yXi2ELbyuaNlFc=";
  };

  cargoDeps = rustPlatform.fetchCargoTarball {
    inherit src;
    name = "${pname}-${version}";
    hash = "sha256-rj9tfOzhzfWBoxBGlTXHAmiH5qxyoLnHhlEijy/q+Ws=";
  };

  nativeBuildInputs = [
    rustPlatform.bindgenHook
    rustPlatform.cargoSetupHook
    rustPlatform.maturinBuildHook
  ];

  buildInputs = lib.optionals stdenv.isDarwin [
    libiconv
    SystemConfiguration
  ];

  env.BORING_BSSL_PATH = boringssl-wrapper;

  optional-dependencies = {
    dev = [ pytest ];
  };

  # Test use network
  doCheck = false;

  pythonImportsCheck = [ "pyreqwest_impersonate" ];

  meta = {
    description = "HTTP client that can impersonate web browsers (Chrome/Edge/OkHttp/Safari), mimicking their headers and TLS/JA3/JA4/HTTP2 fingerprints";
    homepage = "https://github.com/deedy5/pyreqwest_impersonate";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ drupol ];
  };
}