From 30bb75d744ce976dbc9922a8d6f6870ccff288b2 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sun, 12 Apr 2020 17:10:46 +0200 Subject: [PATCH] Cleanup py27 support This repo is now testing only with Python 3, so let's make a few cleanups: - Remove python 2.7 stanza from setup.py - Add requires on python >= 3.6 to setup.cfg so that pypi and pip know about the requirement - Remove obsolete sections from setup.cfg - Update classifiers - Update requirements, no need for python_version anymore - Switch to using sphinx-build - Cleanup */source/conf.py to remove now obsolete content. - Use newer openstackdocstheme version - Use mock from unittest;leave it in test-requirements for now since otherwise lower-constraints fails since some repos expect mock to be installed without requiring it. - Remove future imports, not needed for python3 - Update to newer hacking version for python3, disable one warning. Remove hacking requirements from lower-constraints, they are not needed there. - Cleanup tox.ini, move basepython to top - Update horizon requirement for ussuri Change-Id: I1753bce3ac4fc4248783c0669cacab2e037e62fe --- doc/requirements.txt | 5 ++--- doc/source/conf.py | 3 --- lower-constraints.txt | 9 ++------- releasenotes/source/conf.py | 4 ---- requirements.txt | 2 +- setup.cfg | 8 +++----- setup.py | 9 --------- test-requirements.txt | 7 +++---- tools/install_venv_common.py | 2 -- tox.ini | 14 ++++---------- watcher_dashboard/api/watcher.py | 2 -- .../content/audit_templates/tables.py | 2 -- watcher_dashboard/content/audit_templates/tests.py | 3 ++- watcher_dashboard/content/goals/tests.py | 3 ++- watcher_dashboard/content/strategies/tests.py | 3 ++- watcher_dashboard/test/api_tests/test_watcher.py | 4 ++-- watcher_dashboard/test/helpers.py | 2 +- watcher_dashboard/test/selenium.py | 2 -- 18 files changed, 24 insertions(+), 60 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 92f8ab6..f85dcc8 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -2,6 +2,5 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -openstackdocstheme>=1.18.1 # Apache-2.0 -sphinx>=1.8.0,<2.0.0;python_version=='2.7' # BSD -sphinx>=1.8.0,!=2.1.0;python_version>='3.4' # BSD +openstackdocstheme>=1.31.2 # Apache-2.0 +sphinx>=1.8.0,!=2.1.0 # BSD diff --git a/doc/source/conf.py b/doc/source/conf.py index 56e2547..12d2bf5 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -119,6 +119,3 @@ latex_elements = { repository_name = 'openstack/watcher-dashboard' bug_project = 'watcher-dashboard' bug_tag = '' - -# Must set this variable to include year, month, day, hours, and minutes. -html_last_updated_fmt = '%Y-%m-%d %H:%M' diff --git a/lower-constraints.txt b/lower-constraints.txt index 6bc1664..c8340e1 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -24,10 +24,8 @@ dulwich==0.19.0 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 futurist==1.6.0 -hacking==0.12.0 -horizon==17.1.0 +horizon==18.2.0 httplib2==0.10.3 idna==2.6 imagesize==1.0.0 @@ -40,14 +38,13 @@ jsonschema==2.6.0 keystoneauth1==3.4.0 linecache2==1.0.0 MarkupSafe==1.0 -mccabe==0.2.1 mock==2.0.0 monotonic==1.4 msgpack==0.5.6 munch==2.2.0 netaddr==0.7.19 netifaces==0.10.6 -openstackdocstheme==1.18.1 +openstackdocstheme==1.31.2 openstacksdk==0.12.0 os-client-config==1.29.0 os-service-types==1.2.0 @@ -61,11 +58,9 @@ oslo.utils==3.36.0 osprofiler==2.3.0 packaging==17.1 pbr==2.0.0 -pep8==1.5.7 Pint==0.8.1 prettytable==0.7.2 pycparser==2.18 -pyflakes==0.8.1 Pygments==2.2.0 pymongo==3.6.1 pyOpenSSL==17.5.0 diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 0b89705..e2fad91 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -113,10 +113,6 @@ repository_name = 'openstack/watcher-dashboard' bug_project = 'watcher-dashboard' bug_tag = '' -# Must set this variable to include year, month, day, hours, and minutes. -html_last_updated_fmt = '%Y-%m-%d %H:%M' - - # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. diff --git a/requirements.txt b/requirements.txt index b85ab47..152030e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 -horizon>=17.1.0 # Apache-2.0 +horizon>=18.2.0 # Apache-2.0 PyYAML>=3.12 # MIT python-watcherclient>=1.1.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index 3afa905..56bc960 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,6 +6,7 @@ description-file = author = OpenStack author-email = openstack-discuss@lists.openstack.org home-page = https://docs.openstack.org/watcher-dashboard/latest +python-requires = >=3.6 classifier = Development Status :: 5 - Production/Stable Environment :: OpenStack @@ -17,6 +18,8 @@ classifier = Operating System :: OS Independent Operating System :: POSIX :: Linux Programming Language :: Python + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 @@ -26,11 +29,6 @@ classifier = packages = watcher_dashboard -[build_sphinx] -all_files = 1 -build-dir = doc/build -source-dir = doc/source - [nosetests] verbosity=2 detailed-errors=1 diff --git a/setup.py b/setup.py index 566d844..cd35c3c 100644 --- a/setup.py +++ b/setup.py @@ -13,17 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT import setuptools -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - setuptools.setup( setup_requires=['pbr>=2.0.0'], pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index e409528..affbba6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 mock>=2.0.0 # BSD python-subunit>=1.0.0 # Apache-2.0/BSD @@ -14,7 +14,6 @@ testtools>=2.2.0 # MIT xvfbwrapper>=0.1.3 #license: MIT # Doc requirements -openstackdocstheme>=1.18.1 # Apache-2.0 -sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD -sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2;python_version>='3.4' # BSD +openstackdocstheme>=1.31.2 # Apache-2.0 +sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2 # BSD reno>=2.5.0 # Apache-2.0 diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index 46822e3..d73649c 100644 --- a/tools/install_venv_common.py +++ b/tools/install_venv_common.py @@ -22,8 +22,6 @@ environment, it should be kept strictly compatible with Python 2.6. Synced in from openstack-common """ -from __future__ import print_function - import optparse import os import subprocess diff --git a/tox.ini b/tox.ini index 3285cab..f2c1c30 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = py37,py36,pep8 skipsdist = True [testenv] +basepython = python3 usedevelop = True setenv = VIRTUAL_ENV={envdir} DJANGO_SETTINGS_MODULE=watcher_dashboard.test.settings @@ -26,31 +27,25 @@ commands = watcher_dashboard [testenv:pep8] -basepython = python3 commands = flake8 [testenv:venv] -basepython = python3 commands = {posargs} [testenv:releasenotes] -basepython = python3 commands = sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html [testenv:cover] -basepython = python3 commands = python setup.py testr --coverage --testr-args='{posargs}' [testenv:docs] -basepython = python3 deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt -r{toxinidir}/doc/requirements.txt -commands = python setup.py build_sphinx +commands = sphinx-build -W -b html doc/source doc/build/html [testenv:pdf-docs] -basepython = python3 envdir = {toxworkdir}/docs deps = {[testenv:docs]deps} whitelist_externals = @@ -62,19 +57,18 @@ commands = make -C doc/build/pdf [testenv:debug] -basepython = python3 commands = oslo_debug_helper {posargs} [flake8] # F405 TEMPLATES may be undefined, or defined from star imports # (because it is not easy to avoid this in openstack_dashboard.test.settings) -ignore = F405 +# W504 line break after binary operator +ignore = F405,W504 show-source = True builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,tools [testenv:lower-constraints] -basepython = python3 deps = -c{toxinidir}/lower-constraints.txt -r{toxinidir}/test-requirements.txt diff --git a/watcher_dashboard/api/watcher.py b/watcher_dashboard/api/watcher.py index 01c6782..fa558f3 100644 --- a/watcher_dashboard/api/watcher.py +++ b/watcher_dashboard/api/watcher.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from __future__ import unicode_literals - import logging from django.conf import settings diff --git a/watcher_dashboard/content/audit_templates/tables.py b/watcher_dashboard/content/audit_templates/tables.py index 3acaa63..526eacc 100644 --- a/watcher_dashboard/content/audit_templates/tables.py +++ b/watcher_dashboard/content/audit_templates/tables.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import unicode_literals - from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy import horizon.exceptions diff --git a/watcher_dashboard/content/audit_templates/tests.py b/watcher_dashboard/content/audit_templates/tests.py index de87d90..fd0ae42 100644 --- a/watcher_dashboard/content/audit_templates/tests.py +++ b/watcher_dashboard/content/audit_templates/tests.py @@ -13,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock + from django import urls -import mock from watcher_dashboard import api from watcher_dashboard.test import helpers as test diff --git a/watcher_dashboard/content/goals/tests.py b/watcher_dashboard/content/goals/tests.py index 17a7e0d..bbc9050 100644 --- a/watcher_dashboard/content/goals/tests.py +++ b/watcher_dashboard/content/goals/tests.py @@ -13,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock + from django import urls -import mock from watcher_dashboard import api from watcher_dashboard.test import helpers as test diff --git a/watcher_dashboard/content/strategies/tests.py b/watcher_dashboard/content/strategies/tests.py index 1fc425a..6257728 100644 --- a/watcher_dashboard/content/strategies/tests.py +++ b/watcher_dashboard/content/strategies/tests.py @@ -13,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock + from django import urls -import mock from watcher_dashboard import api from watcher_dashboard.test import helpers as test diff --git a/watcher_dashboard/test/api_tests/test_watcher.py b/watcher_dashboard/test/api_tests/test_watcher.py index 04fc75f..e77d4be 100644 --- a/watcher_dashboard/test/api_tests/test_watcher.py +++ b/watcher_dashboard/test/api_tests/test_watcher.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import -import mock +from unittest import mock + from watcher_dashboard import api from watcher_dashboard.test import helpers as test diff --git a/watcher_dashboard/test/helpers.py b/watcher_dashboard/test/helpers.py index 57155ae..df81d8b 100644 --- a/watcher_dashboard/test/helpers.py +++ b/watcher_dashboard/test/helpers.py @@ -16,7 +16,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from openstack_dashboard.test import helpers diff --git a/watcher_dashboard/test/selenium.py b/watcher_dashboard/test/selenium.py index e0506a5..1893268 100644 --- a/watcher_dashboard/test/selenium.py +++ b/watcher_dashboard/test/selenium.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import absolute_import - import logging from horizon.test import helpers as test