about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2024-06-16 19:29:43 +0200
committerPol Dellaiera <pol.dellaiera@protonmail.com>2024-06-16 22:05:23 +0200
commit7af35f2cc49283748684d89c7e95fb03270dbede (patch)
treecbcb2c6fb0f5d66c7f9615e0f9b16efc89ba8f12 /pkgs
parentb60ebf54c15553b393d144357375ea956f89e9a9 (diff)
python3Packages.pyreqwest-impersonate: init at 0.4.7
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/python-modules/pyreqwest-impersonate/default.nix61
-rw-r--r--pkgs/top-level/python-packages.nix2
2 files changed, 63 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/pyreqwest-impersonate/default.nix b/pkgs/development/python-modules/pyreqwest-impersonate/default.nix
new file mode 100644
index 0000000000000..39e57b633170e
--- /dev/null
+++ b/pkgs/development/python-modules/pyreqwest-impersonate/default.nix
@@ -0,0 +1,61 @@
+{
+  lib,
+  buildPythonPackage,
+  fetchFromGitHub,
+  rustPlatform,
+  pytest,
+  runCommand,
+  boringssl,
+}:
+
+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.7";
+  pyproject = true;
+
+  src = fetchFromGitHub {
+    owner = "deedy5";
+    repo = "pyreqwest_impersonate";
+    rev = "v${version}";
+    hash = "sha256-ck5RqSUgnLAjZ+1A1wQRyRMahJRq3nzYvE+WBpu6wk0=";
+  };
+
+  cargoDeps = rustPlatform.fetchCargoTarball {
+    inherit src;
+    name = "${pname}-${version}";
+    hash = "sha256-eGmx4ftS1D7qb2pPZxp4XE44teXcRwKs3tcKm8otsaM=";
+  };
+
+  nativeBuildInputs = [
+    rustPlatform.bindgenHook
+    rustPlatform.cargoSetupHook
+    rustPlatform.maturinBuildHook
+  ];
+
+  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 ];
+  };
+}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 483cb05e69962..001e1d52423d0 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -10087,6 +10087,8 @@ self: super: with self; {
 
   pyrender = callPackage ../development/python-modules/pyrender { };
 
+  pyreqwest-impersonate = callPackage ../development/python-modules/pyreqwest-impersonate { };
+
   pyrevolve = callPackage ../development/python-modules/pyrevolve { };
 
   pyrfxtrx = callPackage ../development/python-modules/pyrfxtrx { };