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