forked from wikimedia/pywikibot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
271 lines (234 loc) · 9.08 KB
/
setup.py
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
265
266
267
268
269
270
271
# -*- coding: utf-8 -*-
"""Installer script for Pywikibot 3.0 framework."""
#
# (C) Pywikibot team, 2009-2018
#
# Distributed under the terms of the MIT license.
#
from __future__ import (absolute_import, division,
print_function, unicode_literals)
import os
import sys
from setuptools import find_packages, setup
if sys.version_info[:3] < (2, 7, 4):
try:
# Work around a traceback on Python < 2.7.4
# http://bugs.python.org/issue15881#msg170215
import multiprocessing
except ImportError:
pass
else:
_unused = multiprocessing # pyflakes workaround
PYTHON_VERSION = sys.version_info[:3]
PY2 = (PYTHON_VERSION[0] == 2)
versions_required_message = """
Pywikibot is not available on:
{version}
This version of Pywikibot only supports Python 2.7.2+ or 3.4+.
"""
def python_is_supported():
"""Check that Python is supported."""
# Any change to this must be copied to pwb.py
return PYTHON_VERSION >= (3, 4, 0) or PY2 and PYTHON_VERSION >= (2, 7, 2)
if not python_is_supported():
raise RuntimeError(versions_required_message.format(version=sys.version))
test_deps = ['bz2file', 'mock']
dependencies = ['requests>=2.20.0']
extra_deps = {
# Core library dependencies
'eventstreams': ['sseclient>=0.0.18'],
'isbn': ['python-stdnum'],
'Graphviz': ['pydot>=1.2'],
'Google': ['google>=1.7'],
'IRC': ['irc'],
'mwparserfromhell': ['mwparserfromhell>=0.3.3'],
'Tkinter': ['Pillow'],
'security': ['requests[security]', 'pycparser!=2.14'],
'mwoauth': ['mwoauth>=0.2.4,!=0.3.1'],
'html': ['BeautifulSoup4'],
'flake8': [ # Due to incompatibilities between packages the order matters.
'flake8>=3.6.0',
'pydocstyle',
'hacking',
'flake8-coding',
'flake8-comprehensions',
'flake8-docstrings>=1.1.0',
'flake8-future-import',
'flake8-mock>=0.3',
'flake8-per-file-ignores',
'flake8-print>=2.0.1',
'flake8-quotes',
'flake8-string-format',
'flake8-tuple>=0.2.8',
'flake8-no-u-prefixed-strings>=0.2',
'pep8-naming>=0.7',
'pyflakes>=1.1',
]
}
if PY2:
# Additional core library dependencies which are only available on Python 2
extra_deps.update({
'csv': ['unicodecsv'],
'MySQL': ['oursql'],
})
script_deps = {
'flickrripper.py': ['flickrapi', 'Pillow'],
'states_redirect.py': ['pycountry'],
'weblinkchecker.py': ['memento_client>=0.5.1,!=0.6.0'],
'patrol.py': ['mwparserfromhell>=0.3.3'],
}
# lunatic-python is only available for Linux
if sys.platform.startswith('linux'):
script_deps['script_wui.py'] = ['irc', 'lunatic-python', 'crontab']
# The main pywin32 repository contains a Python 2 only setup.py with a small
# wrapper setup3.py for Python 3.
# http://pywin32.hg.sourceforge.net:8000/hgroot/pywin32/pywin32
# The main pywinauto repository doesnt support Python 3.
# The repositories used below have a Python 3 compliant setup.py
dependency_links = [
'git+https://github.com/AlereDevices/lunatic-python.git#egg='
'lunatic-python',
'hg+https://bitbucket.org/TJG/pywin32#egg=pywin32',
'git+https://github.com/vasily-v-ryabov/pywinauto-64#egg=pywinauto',
]
if PYTHON_VERSION == (2, 7, 2):
# work around distutils hardcoded unittest dependency
# work around T106512
import unittest
_unused = unittest
if 'test' in sys.argv:
import unittest2
sys.modules['unittest'] = unittest2
if PY2:
# tools.ip does not have a hard dependency on an IP address module,
# as it falls back to using regexes if one is not available.
# The functional backport of py3 ipaddress is acceptable:
# https://pypi.org/project/ipaddress
# However the Debian package python-ipaddr is also supported:
# https://pypi.org/project/ipaddr
# Other backports are likely broken.
# ipaddr 2.1.10+ is distributed with Debian and Fedora. See T105443.
dependencies.append('ipaddr>=2.1.10')
if PYTHON_VERSION == (2, 7, 2):
dependencies.append('future>=0.15.0') # Bug fixes for HTMLParser
if (2, 7, 6) < PYTHON_VERSION < (2, 7, 9):
# Python versions before 2.7.9 will cause urllib3 to trigger
# InsecurePlatformWarning warnings for all HTTPS requests. By
# installing with security extras, requests will automatically set
# them up and the warnings will stop. See
# <https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning>
# for more details.
# There is no secure version of cryptography for Python 2.7.6 or older.
dependencies += extra_deps['security']
script_deps['data_ingestion.py'] = extra_deps['csv']
try:
import bz2
except ImportError:
# Use bz2file if the python is not compiled with bz2 support.
dependencies.append('bz2file')
else:
_unused = bz2
# Some of the ui_tests depend on accessing the console window's menu
# to set the console font and copy and paste, achieved using pywinauto
# which depends on pywin32.
# These tests may be disabled because pywin32 depends on VC++, is time
# comsuming to build, and the console window cant be accessed during appveyor
# builds.
# Microsoft makes available a compiler for Python 2.7
# http://www.microsoft.com/en-au/download/details.aspx?id=44266
if os.name == 'nt' and os.environ.get('PYSETUP_TEST_NO_UI', '0') != '1':
# which isnt provided on pypi.
test_deps += ['pywin32', 'pywinauto>=0.4.0']
extra_deps.update(script_deps)
# Add all dependencies as test dependencies,
# so all scripts can be compiled for script_tests, etc.
if 'PYSETUP_TEST_EXTRAS' in os.environ:
test_deps += [i for k, v in extra_deps.items() if k != 'flake8' for i in v]
if 'oursql' in test_deps and os.name == 'nt':
test_deps.remove('oursql') # depends on Cython
if 'requests[security]' in test_deps:
# Bug T105767 on Python 2.7 release 9+
if PY2 and PYTHON_VERSION[2] >= 9:
test_deps.remove('requests[security]')
# These extra dependencies are needed other unittest fails to load tests.
if PY2:
test_deps += extra_deps['csv']
else:
test_deps += ['six']
def get_version():
"""Get a valid pywikibot module version string."""
version = '3.0'
try:
import subprocess
date = subprocess.check_output(
['git', 'log', '-1', '--format=%ci']).strip()
date = date.decode().split(' ')[0].replace('-', '')
version += '.' + date
if 'sdist' not in sys.argv:
version += '.dev0'
except Exception as e:
print(e)
version += '.dev0'
return version
def read_desc(filename):
"""Read long description.
Combine included restructured text files which must be done before
uploading because the source isn't available after creating the package.
"""
desc = []
with open(filename) as f:
for line in f:
if line.strip().startswith('.. include::'):
include = os.path.relpath(line.rsplit('::')[1].strip())
if os.path.exists(include):
with open(include) as g:
desc.append(g.read())
else:
print('Cannot include {0}; file not found'.format(include))
else:
desc.append(line)
return ''.join(desc)
name = 'pywikibot'
setup(
name=name,
version=get_version(),
description='Python MediaWiki Bot Framework',
long_description=read_desc('README.rst'),
keywords=('API', 'bot', 'framework', 'mediawiki', 'pwb', 'python',
'pywikibot', 'pywikipedia', 'pywikipediabot', 'wiki',
'wikimedia', 'wikipedia'),
maintainer='The Pywikibot team',
maintainer_email='[email protected]',
license='MIT License',
packages=[str(name)] + [package
for package in find_packages()
if package.startswith('pywikibot.')],
python_requires='>=2.7.2, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
install_requires=dependencies,
dependency_links=dependency_links,
extras_require=extra_deps,
url='https://www.mediawiki.org/wiki/Manual:Pywikibot',
download_url='https://tools.wmflabs.org/pywikibot/',
test_suite='tests.collector',
tests_require=test_deps,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Wiki',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
use_2to3=False
)