about summary refs log tree commit diff
path: root/pkgs/development/python-modules/clustershell/default.nix
blob: f52f290be8d52de7912d63b2bf73854d99981c96 (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
{
  stdenv,
  lib,
  buildPythonPackage,
  fetchPypi,
  setuptools,
  distutils,
  pyyaml,
  openssh,
  unittestCheckHook,
  bc,
  hostname,
  bash,
}:

buildPythonPackage rec {
  pname = "clustershell";
  version = "1.9.2";
  pyproject = true;

  src = fetchPypi {
    pname = "ClusterShell";
    inherit version;
    hash = "sha256-rsF/HG4GNBC+N49b+sDO2AyUI1G44wJNBUwQNPzShD0=";
  };

  build-system = [
    setuptools
    distutils
  ];

  postPatch = ''
    substituteInPlace lib/ClusterShell/Worker/Ssh.py \
      --replace-fail '"ssh"' '"${openssh}/bin/ssh"' \
      --replace-fail '"scp"' '"${openssh}/bin/scp"'

    substituteInPlace lib/ClusterShell/Worker/fastsubprocess.py \
      --replace-fail '"/bin/sh"' '"${bash}/bin/sh"'

    for f in tests/*; do
      substituteInPlace $f \
        --replace-quiet '/bin/hostname'   '${hostname}/bin/hostname' \
        --replace-quiet '/bin/sleep'      'sleep' \
        --replace-quiet '/bin/echo'       'echo' \
        --replace-quiet '/bin/uname'      'uname' \
        --replace-quiet '/bin/false'      'false' \
        --replace-quiet '/bin/true'       'true' \
        --replace-quiet '/usr/bin/printf' 'printf'
    done
  '';

  propagatedBuildInputs = [ pyyaml ];

  nativeCheckInputs = [
    bc
    hostname
    unittestCheckHook
  ];

  pythonImportsCheck = [ "ClusterShell" ];

  unittestFlagsArray = [
    "tests"
    "-p"
    "'*Test.py'"
  ];

  # Many tests want to open network connections
  # https://github.com/cea-hpc/clustershell#test-suite
  #
  # Several tests fail on Darwin
  preCheck = ''
    rm tests/CLIClushTest.py
    rm tests/TreeWorkerTest.py
    rm tests/TaskDistantMixin.py
    rm tests/TaskDistantTest.py
    rm tests/TaskDistantPdshMixin.py
    rm tests/TaskDistantPdshTest.py
    rm tests/TaskRLimitsTest.py
    rm tests/TreeGatewayTest.py
  '';

  meta = with lib; {
    broken = stdenv.hostPlatform.isDarwin;
    description = "Scalable Python framework for cluster administration";
    homepage = "https://cea-hpc.github.io/clustershell";
    license = licenses.lgpl21;
    maintainers = [ maintainers.alexvorobiev ];
  };
}