summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pysnow/default.nix
blob: 67e8b6e691d565b277b12aa7912e55f7ca13fe0d (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
{
  lib,
  brotli,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  httpretty,
  ijson,
  poetry-core,
  python-magic,
  pytz,
  six,
  pytestCheckHook,
  requests-oauthlib,
}:

buildPythonPackage rec {
  pname = "pysnow";
  version = "0.7.16";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rbw";
    repo = "pysnow";
    rev = version;
    hash = "sha256-nKOPCkS2b3ObmBnk/7FTv4o4vwUX+tOtZI5OQQ4HSTY=";
  };

  pythonRelaxDeps = [ "requests-oauthlib" ];

  nativeBuildInputs = [ poetry-core ];

  propagatedBuildInputs = [
    brotli
    ijson
    python-magic
    pytz
    six
    requests-oauthlib
  ];

  nativeCheckInputs = [
    httpretty
    pytestCheckHook
  ];

  patches = [
    # Switch to poetry-core, https://github.com/rbw/pysnow/pull/183
    (fetchpatch {
      name = "switch-to-poetry-core.patch";
      url = "https://github.com/rbw/pysnow/commit/f214a203432b329df5317f3a25b2c0d9b55a9029.patch";
      hash = "sha256-ViRR+9WStlaQwyrLGk/tMOUAcEMY+kB61ZEKGMQJ30o=";
    })
  ];

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace 'ijson = "^2.5.1"' 'ijson = "*"' \
      --replace 'pytz = "^2019.3"' 'pytz = "*"' \
      --replace 'oauthlib = "^3.1.0"' 'oauthlib = "*"'

    # https://github.com/rbw/pysnow/pull/201 doesn't apply via fetchpatch, so we recreate it
    substituteInPlace tests/test_client.py tests/test_oauth_client.py tests/test_params_builder.py tests/test_resource.py \
      --replace-fail "self.assertEquals" "self.assertEqual"
  '';

  pythonImportsCheck = [ "pysnow" ];

  meta = {
    description = "ServiceNow HTTP client library written in Python";
    homepage = "https://github.com/rbw/pysnow";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ almac ];
  };
}