-
Notifications
You must be signed in to change notification settings - Fork 29
/
ansible-setup_py.j2
264 lines (218 loc) · 9.53 KB
/
ansible-setup_py.j2
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/usr/bin/python -tt
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: Ansible Project, 2020
import os
import sys
{%- if version.major >= 8 %}
from setuptools import setup, find_namespace_packages
{%- else %}
from setuptools import setup
{%- endif %}
{%- if version.major < 6 %}
def detect_bad_upgrade():
# prevent direct upgrade from 2.9.x or earlier to 2.10 due to pip limitations
try:
import ansible
except ImportError:
# ansible is not installed
return False
try:
current_version = ansible.__version__.split('.')
current_filename = ansible.__file__
except AttributeError:
# ansible is installed but already broken. We're probably being reinstalled.
return False
try:
current_version = (int(current_version[0]), int(current_version[1]))
except Exception as e:
print("""\n
### ERROR ###
The currently installed ansible found at:
{0}
{%- if ansible_core_package_name == 'ansible-core' %}
is of an unknown version. Since upgrading directly from ansible-2.x, ansible-3, or
ansible-base to ansible-4 or newer with pip is known to cause problems, please uninstall
the old version and install the new version:
pip uninstall ansible # if installed
pip uninstall ansible-base # if installed
pip install ansible
{%- else %}
is of an unknown version. Since upgrading directly from ansible-2.9 or less to
ansible-2.10 with pip is known to cause problems, please uninstall the old version and
install the new version:
pip uninstall ansible
pip install ansible
{%- endif %}
If you have a broken installation, perhaps because {{ ansible_core_package_name }} was installed before
ansible was upgraded, try this to resolve it:
pip install --force-reinstall ansible {{ ansible_core_package_name }}
If ansible is installed in a different location than you will be installing it now
(for example, if the old version is installed by a system package manager to
/usr/lib/python3.8/site-packages/ansible but you are installing the new version into
~/.local/lib/python3.8/site-packages/ansible with `pip install --user ansible`)
or you want to install anyways and cleanup any breakage afterwards, then you may set
the ANSIBLE_SKIP_CONFLICT_CHECK environment variable to ignore this check:
ANSIBLE_SKIP_CONFLICT_CHECK=1 pip install --user ansible
### END ERROR ###
""".format(current_filename))
else:
{%- if ansible_core_package_name == 'ansible-core' %}
if current_version >= (2, 11):
return False
if current_version == (2, 10):
print("""\n
### ERROR ###
Upgrading directly from ansible-2.10, ansible-3, or ansible-base-2.10 to ansible-4
or greater with pip is known to cause problems. Please uninstall the old version found at:
{0}
and install the new version:
pip uninstall ansible # if installed
pip uninstall ansible-base # if installed
pip install ansible
If you have a broken installation, perhaps because {{ ansible_core_package_name }} was installed before
ansible was upgraded, try this to resolve it:
pip install --force-reinstall ansible {{ ansible_core_package_name }}
If ansible is installed in a different location than you will be installing it now
(for example, if the old version is installed by a system package manager to
/usr/lib/python3.8/site-packages/ansible but you are installing the new version into
~/.local/lib/python3.8/site-packages/ansible with `pip install --user ansible`)
or you want to install anyways and cleanup any breakage afterwards, then you may set
the ANSIBLE_SKIP_CONFLICT_CHECK environment variable to ignore this check:
ANSIBLE_SKIP_CONFLICT_CHECK=1 pip install --user ansible
### END ERROR ###
""".format(current_filename))
{%- else %}
if current_version >= (2, 10):
return False
{%- endif %}
print("""\n
### ERROR ###
Upgrading directly from ansible-2.9 or less to ansible-2.10 or greater with pip is
known to cause problems. Please uninstall the old version found at:
{0}
and install the new version:
pip uninstall ansible
pip install ansible
If you have a broken installation, perhaps because {{ ansible_core_package_name }} was installed before
ansible was upgraded, try this to resolve it:
pip install --force-reinstall ansible {{ ansible_core_package_name }}
If ansible is installed in a different location than you will be installing it now
(for example, if the old version is installed by a system package manager to
/usr/lib/python3.8/site-packages/ansible but you are installing the new version into
~/.local/lib/python3.8/site-packages/ansible with `pip install --user ansible`)
or you want to install anyways and cleanup any breakage afterwards, then you may set
the ANSIBLE_SKIP_CONFLICT_CHECK environment variable to ignore this check:
ANSIBLE_SKIP_CONFLICT_CHECK=1 pip install --user ansible
### END ERROR ###
""".format(current_filename))
return True
if not os.environ.get('ANSIBLE_SKIP_CONFLICT_CHECK'):
if detect_bad_upgrade():
sys.exit(1)
{%- endif %}
__version__ = '{{ version }}'
__author__ = 'Ansible, Inc.'
with open('README.rst', 'r') as f:
long_desc = f.read()
setup(
name='ansible',
version=__version__,
description='Radically simple IT automation',
long_description=long_desc,
author=__author__,
author_email='info@ansible.com',
url='https://ansible.com/',
project_urls={
'Bug Tracker': 'https://github.com/ansible/ansible/issues',
'Code of Conduct': 'https://docs.ansible.com/ansible/latest/community/code_of_conduct.html',
'Documentation': 'https://docs.ansible.com/ansible/',
'Mailing lists': 'https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information',
'Source Code': 'https://github.com/ansible/ansible',
},
license='GPLv3+',
python_requires='{{ python_requires }}',
{%- if version.major >= 8 %}
packages=find_namespace_packages(
'.',
include=[
'ansible_collections',
'ansible_collections.*',
],
exclude=[
{%- for collection in collection_names %}
'ansible_collections.{{ collection }}.tests.*',
'ansible_collections.{{ collection }}.tests',
'ansible_collections.{{ collection }}.docs.*',
'ansible_collections.{{ collection }}.docs',
{%- endfor %}
],
),
package_dir={'': '.'},
package_data={
{%- for collection in collection_names %}
'ansible_collections.{{ collection }}': [
'*',
{%- for dir in collection_directories[collection] %}
'{{ dir }}/*', '{{ dir }}/.*',
{%- endfor %}
],
{%- endfor %}
},
{%- else %}
packages=['ansible_collections'],
{%- if version.major >= 6 and collection_exclude_paths %}
exclude_package_data={
'ansible_collections': [
{%- for path in collection_exclude_paths %}
'{{ path }}',
{%- endfor %}
],
},
{%- endif %}
include_package_data=True,
{%- endif %}
install_requires=[
'{{ ansible_core_package_name }} ~= {{ ansible_core_version }}',{{ collection_deps }}
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Framework :: Ansible',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Natural Language :: English',
'Operating System :: POSIX',
{%- if version.major < 5 %}
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
{%- endif %}
{%- if version.major >= 5 and version.major < 7 %}
'Programming Language :: Python :: 3.8',
{%- endif %}
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
{%- if version.major >= 7 %}
'Programming Language :: Python :: 3.11',
{%- endif %}
'Topic :: System :: Installation/Setup',
'Topic :: System :: Systems Administration',
'Topic :: Utilities',
],
data_files=[],
{%- if version >= PypiVer('6.0.0rc1') %}
entry_points={
'console_scripts': [
'ansible-community=ansible_collections.ansible_community:main'
]
},
{%- endif %}
# Installing as zip files would break due to references to __file__
zip_safe=False
)