summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/oslo-concurrency/default.nix
blob: e9244c7bc8438aec4c71e033828ae4bc2814c6d2 (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  bash,
  coreutils,
  debtcollector,
  eventlet,
  fasteners,
  fixtures,
  iana-etc,
  libredirect,
  oslo-config,
  oslo-i18n,
  oslo-utils,
  oslotest,
  pbr,
  setuptools,
  stdenv,
  stestr,
}:

buildPythonPackage rec {
  pname = "oslo-concurrency";
  version = "7.3.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "openstack";
    repo = "oslo.concurrency";
    tag = version;
    hash = "sha256-vZWEeyYkdUl9EL4bw6AIbZgVpKXgakvRyFkQAT5GqJ4=";
  };

  postPatch = ''
    substituteInPlace oslo_concurrency/tests/unit/test_processutils.py \
      --replace-fail "/usr" "" \
      --replace-fail "/bin/bash" "${bash}/bin/bash" \
      --replace-fail "/bin/true" "${coreutils}/bin/true" \
      --replace-fail "/bin/env" "${coreutils}/bin/env"

    substituteInPlace pyproject.toml \
      --replace-fail '"oslo_concurrency"' '"oslo_concurrency", "oslo_concurrency.fixture", "oslo_concurrency.tests"'
  '';

  env.PBR_VERSION = version;

  build-system = [ setuptools ];

  dependencies = [
    debtcollector
    fasteners
    oslo-config
    oslo-i18n
    oslo-utils
    pbr
  ];

  nativeCheckInputs = [
    eventlet
    fixtures
    libredirect.hook
    oslotest
    stestr
  ];

  checkPhase = ''
    echo "nameserver 127.0.0.1" > resolv.conf
    export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)

    stestr run -e <(echo "
    oslo_concurrency.tests.unit.test_lockutils_eventlet.TestInternalLock.test_fair_lock_with_spawn
    oslo_concurrency.tests.unit.test_lockutils_eventlet.TestInternalLock.test_fair_lock_with_spawn_n
    oslo_concurrency.tests.unit.test_lockutils_eventlet.TestInternalLock.test_lock_with_spawn
    oslo_concurrency.tests.unit.test_lockutils_eventlet.TestInternalLock.test_lock_with_spawn_n
    ${lib.optionalString stdenv.hostPlatform.isDarwin ''
      oslo_concurrency.tests.unit.test_lockutils.FileBasedLockingTestCase.test_interprocess_nonblocking_external_lock
      oslo_concurrency.tests.unit.test_lockutils.LockTestCase.test_lock_externally
      oslo_concurrency.tests.unit.test_lockutils.LockTestCase.test_lock_externally_lock_dir_not_exist
      oslo_concurrency.tests.unit.test_processutils.PrlimitTestCase.test_stack_size
    ''}")
  '';

  pythonImportsCheck = [ "oslo_concurrency" ];

  meta = {
    description = "Oslo Concurrency library";
    mainProgram = "lockutils-wrapper";
    homepage = "https://github.com/openstack/oslo.concurrency";
    license = lib.licenses.asl20;
    teams = [ lib.teams.openstack ];
  };
}