1{
2 lib,
3 stdenv,
4 ansible-core,
5 buildPythonPackage,
6 fetchPypi,
7 glibcLocales,
8 importlib-metadata,
9 mock,
10 openssh,
11 packaging,
12 pexpect,
13 pytest-mock,
14 pytest-timeout,
15 pytest-xdist,
16 pytestCheckHook,
17 pythonOlder,
18 python-daemon,
19 pyyaml,
20 setuptools,
21 setuptools-scm,
22}:
23
24buildPythonPackage rec {
25 pname = "ansible-runner";
26 version = "2.4.0";
27 pyproject = true;
28
29 disabled = pythonOlder "3.9";
30
31 src = fetchPypi {
32 inherit pname version;
33 hash = "sha256-gtArJUiDDzelNRe2XII8SvNxBpQGx9ITtckEHUXgxbY=";
34 };
35
36 postPatch = ''
37 substituteInPlace pyproject.toml \
38 --replace '"setuptools>=45, <=69.0.2", "setuptools-scm[toml]>=6.2, <=8.0.4"' '"setuptools", "setuptools-scm"'
39 '';
40
41 build-system = [
42 setuptools
43 setuptools-scm
44 ];
45
46 dependencies = [
47 packaging
48 pexpect
49 python-daemon
50 pyyaml
51 ] ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
52
53 nativeCheckInputs = [
54 ansible-core # required to place ansible CLI onto the PATH in tests
55 glibcLocales
56 pytestCheckHook
57 pytest-mock
58 pytest-timeout
59 pytest-xdist
60 mock
61 openssh
62 ];
63
64 preCheck = ''
65 export HOME=$(mktemp -d)
66 export PATH="$PATH:$out/bin";
67 # avoid coverage flags
68 rm pytest.ini
69 '';
70
71 disabledTests = [
72 # Requires network access
73 "test_callback_plugin_task_args_leak"
74 "test_env_accuracy"
75 # Times out on slower hardware
76 "test_large_stdout_blob"
77 # Failed: DID NOT RAISE <class 'RuntimeError'>
78 "test_validate_pattern"
79 ];
80
81 disabledTestPaths =
82 [
83 # These tests unset PATH and then run executables like `bash` (see https://github.com/ansible/ansible-runner/pull/918)
84 "test/integration/test_runner.py"
85 "test/unit/test_runner.py"
86 ]
87 ++ lib.optionals stdenv.isDarwin [
88 # Integration tests on Darwin are not regularly passing in ansible-runner's own CI
89 "test/integration"
90 # These tests write to `/tmp` which is not writable on Darwin
91 "test/unit/config/test__base.py"
92 ];
93
94 pythonImportsCheck = [ "ansible_runner" ];
95
96 meta = with lib; {
97 description = "Helps when interfacing with Ansible";
98 mainProgram = "ansible-runner";
99 homepage = "https://github.com/ansible/ansible-runner";
100 license = licenses.asl20;
101 maintainers = [ ];
102 };
103}