summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/niquests/default.nix
blob: d6166512aac33f0684d092152d3a46e410659608 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
  buildPythonPackage,
  charset-normalizer,
  cryptography,
  fetchFromGitHub,
  hatchling,
  lib,
  orjson,
  pytest-asyncio,
  pytest-httpbin,
  pytestCheckHook,
  stdenv,
  urllib3-future,
  wassima,
}:

buildPythonPackage rec {
  pname = "niquests";
  version = "3.16.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "jawah";
    repo = "niquests";
    tag = "v${version}";
    hash = "sha256-SfHjzkVgoxLhqzFmR1PiPUHHrHgyHlFUfF0VPv6Ed3Y=";
  };

  build-system = [ hatchling ];

  pythonRelaxDeps = [
    "wassima"
  ];

  dependencies = [
    charset-normalizer
    urllib3-future
    wassima
  ];

  optional-dependencies = {
    inherit (urllib3-future.optional-dependencies)
      brotli
      socks
      ws
      zstd
      ;
    full = [
      orjson
    ]
    ++ urllib3-future.optional-dependencies.brotli
    ++ urllib3-future.optional-dependencies.socks
    ++ urllib3-future.optional-dependencies.qh3
    ++ urllib3-future.optional-dependencies.ws
    ++ urllib3-future.optional-dependencies.zstd;
    http3 = urllib3-future.optional-dependencies.qh3;
    ocsp = urllib3-future.optional-dependencies.qh3;
    speedups = [
      orjson
    ]
    ++ urllib3-future.optional-dependencies.brotli
    ++ urllib3-future.optional-dependencies.zstd;
  };

  pythonImportsCheck = [ "niquests" ];

  nativeCheckInputs = [
    cryptography
    pytest-asyncio
    pytest-httpbin
    pytestCheckHook
  ]
  ++ optional-dependencies.socks;

  disabledTestPaths = [
    # tests connect to the internet
    "tests/test_requests.py"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # NameResolutionError: Failed to resolve 'localhost'
    "tests/test_lowlevel.py"
    "tests/test_testserver.py"
  ];

  disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
    # PermissionError: [Errno 1] Operation not permitted
    "test_use_proxy_from_environment"
  ];

  meta = {
    changelog = "https://github.com/jawah/niquests/blob/${src.tag}/HISTORY.md";
    description = "Simple HTTP library that is a drop-in replacement for Requests";
    homepage = "https://github.com/jawah/niquests";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ dotlambda ];
  };
}