1{
2 lib,
3 brotli,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 httpretty,
8 ijson,
9 poetry-core,
10 python-magic,
11 pytz,
12 six,
13 pytestCheckHook,
14 requests-oauthlib,
15}:
16
17buildPythonPackage rec {
18 pname = "pysnow";
19 version = "0.7.16";
20 format = "pyproject";
21
22 src = fetchFromGitHub {
23 owner = "rbw";
24 repo = "pysnow";
25 rev = version;
26 hash = "sha256-nKOPCkS2b3ObmBnk/7FTv4o4vwUX+tOtZI5OQQ4HSTY=";
27 };
28
29 pythonRelaxDeps = [ "requests-oauthlib" ];
30
31 nativeBuildInputs = [ poetry-core ];
32
33 propagatedBuildInputs = [
34 brotli
35 ijson
36 python-magic
37 pytz
38 six
39 requests-oauthlib
40 ];
41
42 nativeCheckInputs = [
43 httpretty
44 pytestCheckHook
45 ];
46
47 patches = [
48 # Switch to poetry-core, https://github.com/rbw/pysnow/pull/183
49 (fetchpatch {
50 name = "switch-to-poetry-core.patch";
51 url = "https://github.com/rbw/pysnow/commit/f214a203432b329df5317f3a25b2c0d9b55a9029.patch";
52 hash = "sha256-ViRR+9WStlaQwyrLGk/tMOUAcEMY+kB61ZEKGMQJ30o=";
53 })
54 ];
55
56 postPatch = ''
57 substituteInPlace pyproject.toml \
58 --replace 'ijson = "^2.5.1"' 'ijson = "*"' \
59 --replace 'pytz = "^2019.3"' 'pytz = "*"' \
60 --replace 'oauthlib = "^3.1.0"' 'oauthlib = "*"'
61
62 # https://github.com/rbw/pysnow/pull/201 doesn't apply via fetchpatch, so we recreate it
63 substituteInPlace tests/test_client.py tests/test_oauth_client.py tests/test_params_builder.py tests/test_resource.py \
64 --replace-fail "self.assertEquals" "self.assertEqual"
65 '';
66
67 pythonImportsCheck = [ "pysnow" ];
68
69 meta = with lib; {
70 description = "ServiceNow HTTP client library written in Python";
71 homepage = "https://github.com/rbw/pysnow";
72 license = licenses.mit;
73 maintainers = with maintainers; [ almac ];
74 };
75}