jenkins-bot submitted this change.

View Change

Approvals: JJMC89: Looks good to me, but someone else must approve Zhuyifei1999: Looks good to me, approved jenkins-bot: Verified
[4.0] Remove Python 2 dependencies

With this release Python 2 and Python 3.4 is dropped. This patch only
disables Python 2 tests, requirements are Python 3.5+ only and setup.py
has been changed that Python 3.5+ is needed for site package
installation. The pwb.py wrapper and the framework still works with
Python 2 as long as the installed packages are compatible.

- update doc in docs/requirements-py3.txt
- disable Python 2 tests for Appveyor
- disable Python 2 tests for Travis
- disable Python 2 fasttests and update tox.ini
- use Python 3.7 for py27 until integration-config-tox-docker was
updated
- remove outdated requirements in requirements.txt
- remove outdated requirements in dev-requirements.txt
- delete requests-requirements.txt which is no longer needed

setup.py:
- Python 3.5+ is needed to run setup.py
- remove outdated dependencies
- remove Python 2 code parts
- Update python_requires and classifiers

Bug: T239542
Bug: T213287
Change-Id: Ia4640ce891d6e023da2cd722e175cbd737dee0bb
---
M .appveyor.yml
M .travis.yml
M dev-requirements.txt
M docs/requirements-py3.txt
D requests-requirements.txt
M requirements.txt
M setup.py
M tox.ini
8 files changed, 29 insertions(+), 113 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index d11de35..c8140ae 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,20 +23,12 @@

# Test the lowest supported release of each major Python version

- - PYTHON: "C:\\Python274-x64"
- PYTHON_VERSION: "2.7.4"
- PYTHON_ARCH: "64"
-
- PYTHON: "C:\\Python350-x64"
PYTHON_VERSION: "3.5.0"
PYTHON_ARCH: "64"

# Appveyor pre-installs these versions onto build machines

- - PYTHON: "C:\\Python27"
- PYTHON_VERSION: "2.7.x"
- PYTHON_ARCH: "32"
-
- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "32"
@@ -53,10 +45,6 @@
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "32"

- - PYTHON: "C:\\Python27-x64"
- PYTHON_VERSION: "2.7.x"
- PYTHON_ARCH: "64"
-
- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "64"
diff --git a/.travis.yml b/.travis.yml
index 98257dd..7e4cbbd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,6 @@
language: python

python:
- - '2.7'
- '3.5'
- '3.6'
- '3.7'
@@ -145,7 +144,7 @@
- djvulibre-bin
- graphviz
- python-ipaddr
- - python: '2.7'
+ - python: '3.6'
env: LANGUAGE=en FAMILY=wpbeta PYWIKIBOT_SITE_ONLY=1 OAUTH_DOMAIN="en.wikipedia.beta.wmflabs.org"
- python: '3.6'
env: LANGUAGE=zh FAMILY=wpbeta PYWIKIBOT_SITE_ONLY=1 OAUTH_DOMAIN="zh.wikipedia.beta.wmflabs.org"
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 117e4ef..c08d091 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,11 +1,7 @@
# This is a PIP 6+ requirements file for development dependencies
#
-pytest < 5 ; python_version < '3'
-pytest-cov >= 2.6.1 ; python_version < '3'
-pytest < 5 ; python_version == '3.4'
-pytest-cov >= 2.6.1, < 2.9 ; python_version == '3.4'
-pytest ; python_version >= '3.5'
-pytest-cov >= 2.6.1 ; python_version >= '3.5'
+pytest
+pytest-cov >= 2.6.1
pytest-timeout
pytest-runner
pytest-attrib>=0.1.3
@@ -27,7 +23,6 @@
flake8-mock>=0.3
codecov
coverage
-mock ; python_version < '3'

# pywin32 & pywinauto>=0.4.0 are Win32 UI test dependencies that have been
# excluded from this file as they are quite expensive to install, and they
diff --git a/docs/requirements-py3.txt b/docs/requirements-py3.txt
index 8f6e55c..986aee3 100644
--- a/docs/requirements-py3.txt
+++ b/docs/requirements-py3.txt
@@ -1,6 +1,6 @@
# This is a PIP requirements file for building Sphinx documentation of pywikibot
# using sphinx on python3.4.
-# requirements.txt and pywikibot[security] are also needed
+# requirements.txt is also needed

sphinx >= 1.8, != 3.1.0
sphinx-epytext >= 0.0.4
\ No newline at end of file
diff --git a/requests-requirements.txt b/requests-requirements.txt
deleted file mode 100644
index 6518e15..0000000
--- a/requests-requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# This file is DEPRECATED! Use `pip install pywikibot[security]` instead.
-#
-# The period below installs pywikibot[security] from setup.py automatically
-# on Python < 2.7.9.
-.
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index d435d19..69c1e8f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -19,13 +19,7 @@
# $ awk -F '[#>=]' '{print $1}' requirements.txt | xargs apt-cache search

# mandatory; see README-conversion.txt
-requests>=2.20.1,<2.22.0; python_version == '3.4'
-requests>=2.20.1; python_version != '3.4'
-enum34>=1.1.6,!=1.1.8; python_version < '3'
-ipaddress ; python_version < '3'
-pathlib2 ; python_version < '3'
-# requests security extra
-requests[security] ; python_full_version > '2.7.6' and python_full_version < '2.7.9'
+requests>=2.20.1

# OAuth support
# mwoauth 0.2.4 is needed because it supports getting identity information
@@ -35,24 +29,18 @@
# core interwiki_graph.py:
pydot >= 1.2

-# wikistats.py and scripts
-unicodecsv ; python_version < '3'
-
# cosmetic_changes and scripts/isbn
python-stdnum >= 1.13

# GUI
-Pillow >= 6.2.2, < 7.0.0 ; python_version < '3'
-Pillow < 6.0.0 ; python_version == '3.4'
-Pillow >= 6.2.2 ; python_version >= '3.5'
+Pillow >= 6.2.2

# core pagegenerators
google >= 1.7
sseclient >= 0.0.18,!=0.0.23,!=0.0.24

# scripts/flickrripper.py
-flickrapi < 3.0.0 ; python_version < '3.5'
-flickrapi >= 2.2 ; python_version >= '3.5'
+flickrapi >= 2.2

# textlib.py and patrol.py
mwparserfromhell>=0.3.3
diff --git a/setup.py b/setup.py
index 5d5a2e5..ca96d76 100644
--- a/setup.py
+++ b/setup.py
@@ -5,29 +5,25 @@
#
# 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 setup

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.4+ or 3.4+.
+This version of Pywikibot only supports Python 3.5+.
"""


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, 4)
+ return PYTHON_VERSION >= (3, 5, 0)


if not python_is_supported():
@@ -42,27 +38,18 @@
'Google': ['google>=1.7'],
'mwparserfromhell': ['mwparserfromhell>=0.3.3'],
'Tkinter': [ # vulnerability found in Pillow<6.2.2
- 'Pillow>=6.2.2,<7.0.0;python_version<"3"',
- 'Pillow<6.0.0;python_version=="3.4"',
- 'Pillow>=6.2.2;python_version>="3.5"',
- ],
- 'security': [
- 'requests[security]'
- ';python_full_version=="2.7.7" or python_full_version=="2.7.8"',
+ 'Pillow>=6.2.2',
],
'mwoauth': ['mwoauth!=0.3.1,>=0.2.4'],
'html': ['BeautifulSoup4'],
'http': ['fake_useragent'],
'flake8': [ # Due to incompatibilities between packages the order matters.
'flake8>=3.7.5',
- 'pydocstyle<=3.0.0;python_version<"3"',
- 'pydocstyle>=4.0.0;python_version>="3.4"',
+ 'pydocstyle>=4.0.0',
'hacking',
'flake8-coding',
'flake8-comprehensions>=3.1.4;python_version>="3.8"',
- 'flake8-comprehensions>=2.2.0;python_version>="3.5"',
- 'flake8-comprehensions>=2.0.0,<2.2.0;python_version=="3.4"',
- 'flake8-comprehensions<2.0.0;python_version<"3"',
+ 'flake8-comprehensions>=2.2.0',
'flake8-docstrings>=1.3.1',
'flake8-future-import',
'flake8-mock>=0.3',
@@ -74,17 +61,13 @@
'pep8-naming>=0.7',
'pyflakes>=2.1.0',
],
- # Additional core library dependencies which are only available on Python 2
- 'csv': ['unicodecsv;python_version<"3"'],
}


# ------- setup extra_requires for scripts ------- #
script_deps = {
- 'data_ingestion.py': extra_deps['csv'],
'flickrripper.py': [
- 'flickrapi<3.0.0;python_version<"3.5"',
- 'flickrapi>=2.2;python_version>="3.5"',
+ 'flickrapi>=2.2',
] + extra_deps['Tkinter'],
'imageharvest.py': extra_deps['html'],
'isbn.py': extra_deps['isbn'],
@@ -99,21 +82,7 @@

# ------- setup install_requires ------- #
# packages which are mandatory
-dependencies = ['requests>=2.20.1,<2.22.0; python_version == "3.4"',
- 'requests>=2.20.1; python_version != "3.4"',
- 'enum34>=1.1.6,!=1.1.8; python_version < "3"',
- 'ipaddress; python_version < "3"',
- 'pathlib2;python_version<"3"']
-
-# 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']
-
+dependencies = ['requests>=2.20.1']

try:
import bz2
@@ -132,14 +101,10 @@
# These tests may be disabled because pywin32 depends on VC++, is time
# consuming to build, and the console window can't 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':
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"',
+ 'pywinauto>0.6.4',
+ 'pywin32>220',
]

# Add all dependencies as test dependencies,
@@ -147,15 +112,9 @@
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 '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.
-test_deps += extra_deps['csv']
test_deps += extra_deps['eventstreams']
-test_deps += ['six;python_version>="3"']
+test_deps += ['six']


def get_version(name):
@@ -210,13 +169,8 @@

def get_packages(name):
"""Find framework packages."""
- if PY2:
- from setuptools import find_packages
- packages = [package for package in find_packages()
- if package.startswith(name + '.')]
- else:
- from setuptools import find_namespace_packages
- packages = find_namespace_packages(include=[name + '.*'])
+ from setuptools import find_namespace_packages
+ packages = find_namespace_packages(include=[name + '.*'])
return [str(name)] + packages


@@ -235,7 +189,7 @@
maintainer_email='pywikibot@lists.wikimedia.org',
license='MIT License',
packages=get_packages(name),
- python_requires='>=2.7.4, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
+ python_requires='>=3.5.0',
install_requires=dependencies,
extras_require=extra_deps,
url='https://www.mediawiki.org/wiki/Manual:Pywikibot',
@@ -250,10 +204,7 @@
'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 :: 3.7',
diff --git a/tox.ini b/tox.ini
index 701a212..3791b86 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,8 +5,8 @@
skip_missing_interpreters = True
envlist =
commit-message
- flake8-{py27,py3,pypy}
- doctest-{py27,py35}
+ flake8-{py3}
+ doctest-{py35}
test-{py27,py35}

[tox:jenkins]
@@ -14,12 +14,15 @@
# Others are run in their own individual jobs on WM Jenkins
envlist =
commit-message
- flake8-{py27,py3,pypy}
+ flake8-{py3}

[params]
doctest_skip = --ignore-files=(gui\.py|eventstreams\.py)

[testenv]
+basepython =
+ py27: python3.7
+ py35: python3.5
setenv =
VIRTUAL_ENV={envdir}
PYWIKIBOT_NO_USER_CONFIG=2
@@ -38,9 +41,7 @@
fasttest: mock
fasttest: .[scripts]

- fasttest-py27: nose-detecthttp
- fasttest-py27: unicodecsv
-
+ fasttest-py27: nose-detecthttp>=0.1.3
fasttest-py35: mwparserfromhell
fasttest-py35: beautifulsoup4
fasttest-py35: nose-detecthttp>=0.1.3
@@ -58,7 +59,6 @@
nosetests --version
nosetests --with-doctest pywikibot {[params]doctest_skip}
basepython =
- py27: python2.7
py35: python3.5
deps =
nose
@@ -73,7 +73,6 @@
rstcheck --recursive --report warning --ignore-directives automodule,autoclass,autofunction .
basepython = python3.5
deps =
- .[security]
-rrequirements.txt
-rdocs/requirements-py3.txt
rstcheck >= 3.3.1
@@ -83,6 +82,7 @@
# D105: Missing docstring in magic method
# D211: No blank lines allowed before class docstring
# FI12,FI13,FI15: __future__ import "with_statement", "print_function" and "generator_stop" missing
+# FI1: __future__ import "x" missing
# FI5: __future__ import "x" present
# H101: TODO format
# H236: Mandatory use of six for Python 2 & 3 metaclass support
@@ -100,7 +100,7 @@
# D412: No blank lines allowed between a section header and its content
# D413: Missing blank line after last section

-ignore = D105,D211,D401,D413,D412,FI12,FI13,FI15,FI16,FI17,FI5,H101,H236,H301,H404,H405,H903,P101,P102,P103,W503
+ignore = D105,D211,D401,D413,D412,FI1,FI5,H101,H236,H301,H404,H405,H903,P101,P102,P103,W503
enable-extensions = H203,H204,H205
exclude = .tox,.git,./*.egg,build,scripts/archive/*,./scripts/i18n/*
min-version = 2.7

To view, visit change 609486. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia4640ce891d6e023da2cd722e175cbd737dee0bb
Gerrit-Change-Number: 609486
Gerrit-PatchSet: 12
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged