1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 python,
6 pythonOlder,
7 installShellFiles,
8 docutils,
9 setuptools,
10 ansible,
11 cryptography,
12 jinja2,
13 junit-xml,
14 lxml,
15 ncclient,
16 packaging,
17 paramiko,
18 ansible-pylibssh,
19 pexpect,
20 psutil,
21 pycrypto,
22 pyyaml,
23 requests,
24 resolvelib,
25 scp,
26 windowsSupport ? false,
27 pywinrm,
28 xmltodict,
29 # Additional packages to add to dependencies
30 extraPackages ? _: [ ],
31}:
32
33buildPythonPackage rec {
34 pname = "ansible-core";
35 version = "2.18.7";
36 pyproject = true;
37
38 disabled = pythonOlder "3.11";
39
40 src = fetchPypi {
41 pname = "ansible_core";
42 inherit version;
43 hash = "sha256-GhKb+fzV3KKxfoPOdxR+4vvDxRpJWJcBUol8xbbQquc=";
44 };
45
46 # ansible_connection is already wrapped, so don't pass it through
47 # the python interpreter again, as it would break execution of
48 # connection plugins.
49 postPatch = ''
50 patchShebangs --build packaging/cli-doc/build.py
51
52 SETUPTOOLS_PATTERN='"setuptools[0-9 <>=.,]+"'
53 PYPROJECT=$(cat pyproject.toml)
54 if [[ "$PYPROJECT" =~ $SETUPTOOLS_PATTERN ]]; then
55 echo "setuptools replace: ''${BASH_REMATCH[0]}"
56 echo "''${PYPROJECT//''${BASH_REMATCH[0]}/'"setuptools"'}" > pyproject.toml
57 else
58 exit 2
59 fi
60
61 substituteInPlace pyproject.toml \
62 --replace-fail "wheel == 0.45.1" wheel
63 '';
64
65 nativeBuildInputs = [
66 installShellFiles
67 docutils
68 ];
69
70 build-system = [ setuptools ];
71
72 dependencies = [
73 # depend on ansible instead of the other way around
74 ansible
75 # from requirements.txt
76 cryptography
77 jinja2
78 packaging
79 pyyaml
80 resolvelib
81 # optional dependencies
82 junit-xml
83 lxml
84 ncclient
85 paramiko
86 ansible-pylibssh
87 pexpect
88 psutil
89 pycrypto
90 requests
91 scp
92 xmltodict
93 ]
94 ++ lib.optionals windowsSupport [ pywinrm ]
95 ++ extraPackages python.pkgs;
96
97 pythonRelaxDeps = [ "resolvelib" ];
98
99 postInstall = ''
100 export HOME="$(mktemp -d)"
101 packaging/cli-doc/build.py man --output-dir=man
102 installManPage man/*
103 '';
104
105 # internal import errors, missing dependencies
106 doCheck = false;
107
108 meta = with lib; {
109 changelog = "https://github.com/ansible/ansible/blob/v${version}/changelogs/CHANGELOG-v${lib.versions.majorMinor version}.rst";
110 description = "Radically simple IT automation";
111 homepage = "https://www.ansible.com";
112 license = licenses.gpl3Plus;
113 maintainers = with maintainers; [
114 HarisDotParis
115 robsliwi
116 ];
117 };
118}