jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/524793 )
Change subject: [setup] Combine setup requirements for different python versions
......................................................................
[setup] Combine setup requirements for different python versions
There are still remaining dependencies like os.environ variables
which cannot combined in such way
Bug: T227409
Change-Id: I552f1a8a3e913904b10979a899470037d51552dc
---
M setup.py
1 file changed, 58 insertions(+), 59 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 6262505..ebc6086 100644
--- a/setup.py
+++ b/setup.py
@@ -33,18 +33,7 @@
if not python_is_supported():
raise RuntimeError(versions_required_message.format(version=sys.version))
-test_deps = ['bz2file', 'mock']
-
-dependencies = ['requests>=2.20.0']
-
-pydocstyle = 'pydocstyle<=3.0.0' if PY2 else
'pydocstyle>=2.5.0,!=4.0.0'
-if PY2:
- pillow = 'Pillow<7.0.0'
-elif PYTHON_VERSION < (3, 5):
- pillow = 'Pillow<6.0.0'
-else:
- pillow = 'Pillow'
-
+# ------- setup extra_requires ------- #
extra_deps = {
# Core library dependencies
'eventstreams': ['sseclient>=0.0.18,!=0.0.23,!=0.0.24'],
@@ -52,14 +41,23 @@
'Graphviz': ['pydot>=1.2'],
'Google': ['google>=1.7'],
'mwparserfromhell': ['mwparserfromhell>=0.3.3'],
- 'Tkinter': [pillow],
- 'security': ['requests[security]', 'pycparser!=2.14'],
+ 'Tkinter': [
+ 'Pillow<7.0.0;python_version<"3"',
+ 'Pillow<6.0.0;python_version=="3.4"',
+ 'Pillow;python_version>="3.5"',
+ ],
+ 'security': [
+ 'requests[security]'
+ ';python_full_version=="2.7.7" or
python_full_version=="2.7.8"',
+ 'pycparser!=2.14',
+ ],
'mwoauth': ['mwoauth>=0.2.4,!=0.3.1'],
'html': ['BeautifulSoup4'],
'http': ['fake_useragent'],
'flake8': [ # Due to incompatibilities between packages the order matters.
'flake8>=3.7.5',
- pydocstyle,
+ 'pydocstyle<=3.0.0;python_version<"3"',
+ 'pydocstyle>=2.5.0,!=4.0.0;python_version>="3.4"',
'hacking',
'flake8-coding',
'flake8-comprehensions',
@@ -73,49 +71,53 @@
'flake8-no-u-prefixed-strings>=0.2',
'pep8-naming>=0.7',
'pyflakes>=2.1.0',
- ]
+ ],
+ # Additional core library dependencies which are only available on Python 2
+ 'csv': ['unicodecsv;python_version<"3"'],
}
-if PY2:
- # Additional core library dependencies which are only available on Python 2
- extra_deps.update({
- 'csv': ['unicodecsv'],
- })
+# ------- setup extra_requires for scripts ------- #
script_deps = {
- 'flickrripper.py': ['flickrapi', pillow],
+ 'flickrripper.py': [
+ 'flickrapi',
+ 'Pillow<7.0.0;python_version<"3"',
+ 'Pillow<6.0.0;python_version=="3.4"',
+ 'Pillow;python_version>="3.5"',
+ ],
'states_redirect.py': ['pycountry'],
'weblinkchecker.py': ['memento_client>=0.5.1,!=0.6.0'],
'patrol.py': ['mwparserfromhell>=0.3.3'],
}
+script_deps['data_ingestion.py'] = extra_deps['csv']
+extra_deps.update(script_deps)
-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')
+# ------- setup install_requires ------- #
+dependencies = ['requests>=2.20.0']
+# 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;python_version<"3"')
- # version.package_version() uses pathlib which is a python 3 library.
- # pathlib2 is required for python 2.7
- dependencies.append('pathlib2')
+# version.package_version() uses pathlib which is a python 3 library.
+# pathlib2 is required for python 2.7
+dependencies.append('pathlib2;python_version<"3"')
- 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']
+# 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
@@ -123,9 +125,11 @@
# Use bz2file if the python is not compiled with bz2 support.
dependencies.append('bz2file')
else:
- _unused = bz2
+ assert bz2
+# ------- setup tests_require ------- #
+test_deps = ['bz2file', 'mock']
# 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.
@@ -135,15 +139,12 @@
# 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':
- if PYTHON_VERSION >= (3, 5, 0) or PY2:
- pywinauto = 'pywinauto>0.6.4'
- pywin32 = 'pywin32>220'
- else: # Python 3.4
- pywinauto = 'pywinauto<=0.6.4'
- pywin32 = 'pywin32<=220'
- test_deps += [pywin32, pywinauto]
-
-extra_deps.update(script_deps)
+ test_deps += [
+ 'pywinauto>0.6.4;python_version>="3.5" or
python_version<"3"',
+ 'pywinauto<=0.6.4;python_version=="3.4"',
+ 'pywin32>220;python_version>="3.5" or
python_version<"3"',
+ 'pywin32<=220;python_version=="3.4"',
+ ]
# Add all dependencies as test dependencies,
# so all scripts can be compiled for script_tests, etc.
@@ -156,10 +157,8 @@
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']
+test_deps += extra_deps['csv']
+test_deps += ['six;python_version>="3"']
def get_version():
--
To view, visit
https://gerrit.wikimedia.org/r/524793
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I552f1a8a3e913904b10979a899470037d51552dc
Gerrit-Change-Number: 524793
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)