summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/consul/default.nix
blob: bac1c1db892c46ab4713d799b4b9db6bcc383427 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  setuptools,
  requests,
  pytestCheckHook,
  aiohttp,
  pytest-asyncio,
  pytest-cov-stub,
  python,
}:

buildPythonPackage rec {
  pname = "py-consul";
  version = "1.7.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "criteo";
    repo = "py-consul";
    tag = "v${version}";
    hash = "sha256-DpGSiwpxAF1kCraRFl6XPJ1eSzvR6Rdq8PkK30J/vA0=";
  };

  patches = [
    (fetchpatch {
      url = "https://salsa.debian.org/python-team/packages/python-consul/-/raw/master/debian/patches/avoir-usr-requirements.txt.patch";
      hash = "sha256-lB9Irzuc2IpbQOIP/C3JQ4iYqugf1U6CVlAEXrrFUfI=";
    })

    # conftest.py always imports docker, even if related tests are disabled
    ./disable-docker-tests.patch
  ];

  build-system = [
    setuptools
  ];

  dependencies = [
    requests
    aiohttp
  ];

  # Exclude sphinx config from installation
  postInstall = ''
    rm -r $out/${python.sitePackages}/docs
  '';

  nativeCheckInputs = [
    pytestCheckHook
    pytest-asyncio
    pytest-cov-stub
  ];

  # Most tests want to run a consul docker container ("hashicorp/consul:{version}" in conftest.py)
  # See also https://salsa.debian.org/python-team/packages/python-consul/-/blob/936c1d9ce3acaac3fa2b6e9384102e843adbbe0b/debian/rules
  disabledTests = [
    "test_acl_token_permission_denied"
    "test_acl_token_list"
    "test_acl_token_read"
    "test_acl_token_create"
    "test_acl_token_clone"
    "test_acl_token_update"
    "test_acl_policy_list"
    "test_acl_policy_read"
    "test_agent_checks"
    "test_service_multi_check"
    "test_service_dereg_issue_156"
    "test_agent_checks_service_id"
    "test_agent_register_check_no_service_id"
    "test_agent_register_enable_tag_override"
    "test_agent_service_maintenance"
    "test_agent_node_maintenance"
    "test_agent_members"
    "test_agent_self"
    "test_agent_services"
    "test_coordinate"
    "test_event"
    "test_event_targeted"
    "test_health_service"
    "test_health_state"
    "test_health_service"
    "test_health_state"
    "test_health_node"
    "test_health_checks"
    "test_kv"
    "test_kv_wait"
    "test_kv_encoding"
    "test_kv_put_cas"
    "test_kv_put_flags"
    "test_kv_recurse"
    "test_kv_delete"
    "test_kv_delete_cas"
    "test_kv_acquire_release"
    "test_kv_keys_only"
    "test_kv_acquire_release"
    "test_kv_keys_only"
    "test_operator"
    "test_session"
    "test_session_delete_ttl_renew"
    "test_status_leader"
    "test_status_peers"
    "test_transaction"
    "test_consul_ctor"
    "test_acl_token_delete"
    "test_acl_templated_policy_list"
    "test_acl_templated_policy_preview"
    "test_acl_templated_policy_read"
    "test_acl_templated_policy_wrote"
    "test_agent_service_tagged_addresses"
    "test_agent_service_connect"
  ];

  pythonImportsCheck = [ "consul" ];

  meta = {
    description = "Python client for Consul (https://www.consul.io/)";
    homepage = "https://github.com/criteo/py-consul";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      panicgh
    ];
  };
}