about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/networking/ripe-atlas-tools/default.nix
blob: 0fc3897b8780731c45a4163f5ea991edb275c3f6 (plain) (blame)
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
{ lib
, python3
, fetchFromGitHub
, installShellFiles
}:

python3.pkgs.buildPythonApplication rec {
  pname = "ripe-atlas-tools";
  version = "3.1.0";

  src = fetchFromGitHub {
    owner = "RIPE-NCC";
    repo = "ripe-atlas-tools";
    rev = "refs/tags/v${version}";
    hash = "sha256-aETSDXCVteTruRKV/8Aw3R/bprB6txOsXrFvoZOxIus=";
  };

  postPatch = ''
    # This mapping triggers network access on docs generation: https://github.com/RIPE-NCC/ripe-atlas-tools/issues/235
    sed -i '/^intersphinx_mapping/d' docs/conf.py
    # TODO: Ensure user-agent is picked up during build, remove me when https://github.com/RIPE-NCC/ripe-atlas-tools/pull/236
    echo "include ripe/atlas/tools/user-agent" >> MANIFEST.in
  '';

  nativeBuildInputs = with python3.pkgs; [
    sphinx-rtd-theme
    sphinxHook
    installShellFiles
  ];

  propagatedBuildInputs = with python3.pkgs; [
    ipy
    pyopenssl
    python-dateutil
    pyyaml
    requests
    ripe-atlas-cousteau
    ripe-atlas-sagan
    typing-extensions
    tzlocal
    ujson
  ];

  preBuild = ''
    echo "RIPE Atlas Tools [NixOS ${version}" > ripe/atlas/tools/user-agent
  '';

  postInstall = ''
    installShellCompletion --cmd ripe-atlas --bash ./ripe-atlas-bash-completion.sh
  '';

  pythonImportsCheck = [
    "ripe.atlas.tools"
  ];

  nativeCheckInputs = with python3.pkgs; [
    pytestCheckHook
  ];

  disabledTests = [
    # Network tests: https://github.com/RIPE-NCC/ripe-atlas-tools/issues/234
    "test_arg_from_file"
    "test_arg_from_stdin"
    # We injected our user-agent so the tests will fail
    "test_user_agent_mac"
    "test_user_agent_windows"
    "test_user_agent_xdg_absent"
    "test_user_agent_xdg_present"
  ];

  disabledTestPaths = [
    # Relies on `ripe-atlas` being available in the PATH, installed with autocompletions
    "tests/test_bash_completion.py"
    # AS lookups are not mocked up: https://github.com/RIPE-NCC/ripe-atlas-tools/blob/master/tests/renderers/test_traceroute_aspath.py#L26
    "tests/renderers/test_traceroute_aspath.py"
    # We already build Sphinx so we do not need to test it
    "tests/test_docs.py"
  ];

  HOME = "$TMPDIR"; # for cache generation.

  # Necessary because it confuse the tests when it does "from ripe.atlas.sagan import X"
  # version.py is used by Sphinx tests.
  preCheck = ''
    rm -rf ripe
    mkdir -p ripe/atlas/tools
    echo "__version__ = \"${version}\"" > ripe/atlas/tools/version.py
  '';

  meta = with lib; {
    description = "RIPE ATLAS project tools";
    homepage = "https://github.com/RIPE-NCC/ripe-atlas-tools";
    changelog = "https://github.com/RIPE-NCC/ripe-atlas-tools/blob/v${version}/CHANGES.rst";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ raitobezarius ];
  };
}