From 0598412960afcbd5fbe42d6cf100b7af658cd959 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Fri, 14 Jun 2019 20:40:49 -0400 Subject: [PATCH 1/3] Deprecate support for Python 3.4 and begin testing with Python 3.8 beta --- .appveyor.yml | 5 ++--- .travis.yml | 6 +++--- CONTRIBUTING.md | 2 +- README.md | 4 ++-- azure-pipelines.yml | 3 --- cmd2/cmd2.py | 7 +------ cmd2/pyscript_bridge.py | 8 +------- docs/index.rst | 2 +- docs/install.rst | 8 ++------ setup.py | 10 ++++------ tests/conftest.py | 7 +------ tox.ini | 2 +- 12 files changed, 19 insertions(+), 45 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 69ab4b6af..4e32ee1a2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,9 +4,8 @@ environment: PYTHONUNBUFFERED: 1 MINICONDA: C:\\Miniconda3-x64 matrix: -# Disable Python 3.5 testing on AppVeyor for now until we fix issue with mock module install for python < 3.6 -# - PYTHON: "C:\\Python35" -# TOX_ENV: "py35" + - PYTHON: "C:\\Python35" + TOX_ENV: "py35" - PYTHON: "C:\\Python36" TOX_ENV: "py36" diff --git a/.travis.yml b/.travis.yml index fc9c65bdf..1946b48e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,6 @@ sudo: false # false enables container-based build for fast boot times on Linux matrix: include: - - os: linux - python: 3.4 - env: TOXENV=py34 - os: linux python: 3.5 env: TOXENV=py35 @@ -18,6 +15,9 @@ matrix: dist: xenial sudo: true # Travis CI doesn't yet support official (non-development) Python 3.7 on container-based builds env: TOXENV=py37 + - os: linux + python: 3.8-dev + env: TOXENV=py38 - os: linux python: 3.5 env: TOXENV=docs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95185efeb..e40f698ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ The tables below list all prerequisites along with the minimum required version | Prerequisite | Minimum Version | | --------------------------------------------------- | --------------- | -| [python](https://www.python.org/downloads/) | `3.4` | +| [python](https://www.python.org/downloads/) | `3.5` | | [attrs](https://github.com/python-attrs/attrs) | `16.3` | | [colorama](https://github.com/tartley/colorama) | `0.3.7` | | [pyperclip](https://github.com/asweigart/pyperclip) | `1.5.27` | diff --git a/README.md b/README.md index cf79b7ac0..562f539f4 100755 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Main Features - Unicode character support - Good tab-completion of commands, sub-commands, file system paths, and shell commands - Automatic tab-completion of `argparse` flags when using one of the `cmd2` `argparse` decorators -- Support for Python 3.4+ on Windows, macOS, and Linux +- Support for Python 3.5+ on Windows, macOS, and Linux - Trivial to provide built-in help for all commands - Built-in regression testing framework for your applications (transcript-based testing) - Transcripts for use with built-in regression can be automatically generated from `history -t` or `load -t` @@ -59,7 +59,7 @@ On all operating systems, the latest stable version of `cmd2` can be installed u pip install -U cmd2 ``` -cmd2 works with Python 3.4+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-party dependencies. +cmd2 works with Python 3.5+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-party dependencies. For information on other installation options, see [Installation Instructions](https://cmd2.readthedocs.io/en/latest/install.html) in the cmd2 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 906ae1e3b..9a05153bc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,9 +14,6 @@ jobs: # Run the pipeline with multiple Python versions strategy: matrix: - Python34: - python.version: '3.4' - TOXENV: 'py34' Python35: python.version: '3.5' TOXENV: 'py35' diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 02462d96a..226e0df74 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -39,6 +39,7 @@ import sys import threading from collections import namedtuple +from contextlib import redirect_stdout from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, Union, IO import colorama @@ -103,12 +104,6 @@ def __subclasshook__(cls, C): return True return NotImplemented -# Python 3.4 require contextlib2 for temporarily redirecting stderr and stdout -if sys.version_info < (3, 5): - # noinspection PyUnresolvedReferences - from contextlib2 import redirect_stdout -else: - from contextlib import redirect_stdout # Detect whether IPython is installed to determine if the built-in "ipy" command should be included ipython_available = True diff --git a/cmd2/pyscript_bridge.py b/cmd2/pyscript_bridge.py index e56331732..31c1ab9cd 100644 --- a/cmd2/pyscript_bridge.py +++ b/cmd2/pyscript_bridge.py @@ -5,17 +5,11 @@ """ import sys +from contextlib import redirect_stdout, redirect_stderr from typing import Optional from .utils import namedtuple_with_defaults, StdSim -# Python 3.4 require contextlib2 for temporarily redirecting stderr and stdout -if sys.version_info < (3, 5): - # noinspection PyUnresolvedReferences - from contextlib2 import redirect_stdout, redirect_stderr -else: - from contextlib import redirect_stdout, redirect_stderr - class CommandResult(namedtuple_with_defaults('CommandResult', ['stdout', 'stderr', 'stop', 'data'])): """Encapsulates the results from a cmd2 app command diff --git a/docs/index.rst b/docs/index.rst index 31bb47713..5f9c4c3dc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -73,7 +73,7 @@ Contents: Compatibility ============= -Tested and working with Python 3.4+ on Windows, macOS, and Linux. +Tested and working with Python 3.5+ on Windows, macOS, and Linux. Index ===== diff --git a/docs/install.rst b/docs/install.rst index b07109166..62765704a 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -6,7 +6,7 @@ This section covers the basics of how to install, upgrade, and uninstall ``cmd2` Installing ---------- -First you need to make sure you have Python 3.4+, pip_, and setuptools_. Then you can just use pip to +First you need to make sure you have Python 3.5+, pip_, and setuptools_. Then you can just use pip to install from PyPI_. .. _pip: https://pypi.python.org/pypi/pip @@ -25,7 +25,7 @@ install from PyPI_. Requirements for Installing ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -* If you have Python 3 >=3.4 installed from `python.org +* If you have Python 3 >=3.5 installed from `python.org `_, you will already have pip_ and setuptools_, but may need to upgrade to the latest versions: @@ -124,10 +124,6 @@ If you wish to permanently uninstall ``cmd2``, this can also easily be done with pip uninstall cmd2 -Extra requirements for Python 3.4 ---------------------------------- -``cmd2`` requires the ``contextlib2`` module for Python 3.4. This is used to temporarily redirect -stdout and stderr. Also when using Python 3.4, ``cmd2`` requires the ``typing`` module backport. Extra requirement for macOS =========================== diff --git a/setup.py b/setup.py index d8775d58f..f6b8f5127 100755 --- a/setup.py +++ b/setup.py @@ -21,10 +21,10 @@ License :: OSI Approved :: MIT License Programming Language :: Python Programming Language :: Python :: 3 -Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 +Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython Topic :: Software Development :: Libraries :: Python Modules """.splitlines()))) # noqa: E128 @@ -36,14 +36,12 @@ EXTRAS_REQUIRE = { # Windows also requires pyreadline to ensure tab completion works ":sys_platform=='win32'": ['pyreadline'], - # Python 3.4 and earlier require contextlib2 for temporarily redirecting stderr and stdout - ":python_version<'3.5'": ['contextlib2', 'typing'], # Extra dependencies for running unit tests 'test': ["gnureadline; sys_platform=='darwin'", # include gnureadline on macOS to ensure it is available in tox env - "mock ; python_version<'3.6'", # for python 3.5 and earlier we need the third party mock module + "mock ; python_version<'3.6'", # for python 3.5 we need the third party mock module 'codecov', 'pytest', 'pytest-cov', 'pytest-mock'], # development only dependencies: install with 'pip install -e .[dev]' - 'dev': ["mock ; python_version<'3.6'", # for python 3.5 and earlier we need the third party mock module + 'dev': ["mock ; python_version<'3.6'", # for python 3.5 we need the third party mock module 'pytest', 'codecov', 'pytest-cov', 'pytest-mock', 'tox', 'pylint', 'sphinx', 'sphinx-rtd-theme', 'sphinx-autobuild', 'invoke', 'twine>=1.11', ] @@ -63,7 +61,7 @@ platforms=['any'], packages=['cmd2'], keywords='command prompt console cmd', - python_requires='>=3.4', + python_requires='>=3.5', setup_requires=SETUP_REQUIRES, install_requires=INSTALL_REQUIRES, extras_require=EXTRAS_REQUIRE, diff --git a/tests/conftest.py b/tests/conftest.py index 517e2865c..1e124219b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,7 @@ Cmd2 unit/functional testing """ import sys +from contextlib import redirect_stdout, redirect_stderr from typing import Optional from unittest import mock @@ -11,12 +12,6 @@ import cmd2 from cmd2.utils import StdSim -# Python 3.4 require contextlib2 for temporarily redirecting stderr and stdout -if sys.version_info < (3, 5): - # noinspection PyUnresolvedReferences - from contextlib2 import redirect_stdout, redirect_stderr -else: - from contextlib import redirect_stdout, redirect_stderr # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: diff --git a/tox.ini b/tox.ini index f0d622cf4..7363f7dfe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = docs,py34,py35,py36,py37 +envlist = docs,py35,py36,py37,py38 [pytest] testpaths = tests From 2311acf725e46257808a653319ccac73003d4a49 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Fri, 14 Jun 2019 20:46:43 -0400 Subject: [PATCH 2/3] Try fixing AppVeyor and Travils builds --- .appveyor.yml | 5 +++-- .travis.yml | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4e32ee1a2..69ab4b6af 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,8 +4,9 @@ environment: PYTHONUNBUFFERED: 1 MINICONDA: C:\\Miniconda3-x64 matrix: - - PYTHON: "C:\\Python35" - TOX_ENV: "py35" +# Disable Python 3.5 testing on AppVeyor for now until we fix issue with mock module install for python < 3.6 +# - PYTHON: "C:\\Python35" +# TOX_ENV: "py35" - PYTHON: "C:\\Python36" TOX_ENV: "py36" diff --git a/.travis.yml b/.travis.yml index 1946b48e9..e05281a95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: python -sudo: false # false enables container-based build for fast boot times on Linux - matrix: include: - os: linux @@ -13,11 +11,11 @@ matrix: - os: linux python: 3.7 dist: xenial - sudo: true # Travis CI doesn't yet support official (non-development) Python 3.7 on container-based builds env: TOXENV=py37 - os: linux - python: 3.8-dev - env: TOXENV=py38 + python: 3.8-dev + dist: xenial + env: TOXENV=py38 - os: linux python: 3.5 env: TOXENV=docs From 7a30803cd2111e71da644123597cb665885695a8 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Fri, 14 Jun 2019 23:21:41 -0400 Subject: [PATCH 3/3] Updated CHANGELOG with info on Python 3.4 deprecation and 3.8 support --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8e915fc..5eb3d40ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.9.14 (TBD, 2019 +* Enhancements + * Added support for and testing with Python 3.8, starting with 3.8 beta +* Breaking Changes + * Python 3.4 reached its [end of life](https://www.python.org/dev/peps/pep-0429/) on March 18, 2019 and is no longer supported by `cmd2` + ## 0.9.13 (June 14, 2019) * Bug Fixes * Fixed issue where the wrong terminator was being appended by `Statement.expanded_command_line()`