From d9bd72895614db20d517c115b59f76e888b24642 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 26 May 2020 13:28:01 +0100 Subject: [PATCH] Remove support for python < 3.6 (#1386) * Remove support for python2.7 Python 2.7 is officially dead and we are not going to make any new release that supports it. This removes py27 code but a follow-up will address other changes like dropping the need to use six library. * Remove python 3.5 * Restore travis Co-authored-by: Andrey Shpak --- .github/workflows/main.yml | 40 -------------------------------- .travis.yml | 47 ++++++-------------------------------- CONTRIBUTING.md | 4 ++-- README.md | 6 ++--- cookiecutter/vcs.py | 5 +--- cookiecutter/zipfile.py | 8 +------ docs/installation.rst | 7 +++--- pyproject.toml | 2 +- setup.py | 28 +++++++++++++---------- tox.ini | 3 --- 10 files changed, 34 insertions(+), 116 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f20aa172..36ebf2fed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,24 +19,16 @@ jobs: name: - "linting" - - "ubuntu-py27" - - "ubuntu-py35" - "ubuntu-py36" - "ubuntu-py37" - "ubuntu-py38" - - "ubuntu-pypy" - "ubuntu-pypy3" - - "macos-py27" - - "macos-py35" - "macos-py36" - "macos-py37" - "macos-py38" - - "macos-pypy" - "macos-pypy3" - - "windows-py27" - - "windows-py35" - "windows-py36" - "windows-py37" - "windows-py38" @@ -47,14 +39,6 @@ jobs: os: ubuntu-latest tox_env: "lint" - - name: "ubuntu-py27" - python: "2.7" - os: ubuntu-latest - tox_env: "py27" - - name: "ubuntu-py35" - python: "3.5" - os: ubuntu-latest - tox_env: "py35" - name: "ubuntu-py36" python: "3.6" os: ubuntu-latest @@ -67,23 +51,11 @@ jobs: python: "3.8" os: ubuntu-latest tox_env: "py38" - - name: "ubuntu-pypy" - python: "pypy2" - os: ubuntu-latest - tox_env: "pypy" - name: "ubuntu-pypy3" python: "pypy3" os: ubuntu-latest tox_env: "pypy3" - - name: "macos-py27" - python: "2.7" - os: macos-latest - tox_env: "py27" - - name: "macos-py35" - python: "3.5" - os: macos-latest - tox_env: "py35" - name: "macos-py36" python: "3.6" os: macos-latest @@ -96,23 +68,11 @@ jobs: python: "3.8" os: macos-latest tox_env: "py38" - - name: "macos-pypy" - python: "pypy2" - os: macos-latest - tox_env: "pypy" - name: "macos-pypy3" python: "pypy3" os: macos-latest tox_env: "pypy3" - - name: "windows-py27" - python: "2.7" - os: windows-latest - tox_env: "py27" - - name: "windows-py35" - python: "3.5" - os: windows-latest - tox_env: "py35" - name: "windows-py36" python: "3.6" os: windows-latest diff --git a/.travis.yml b/.travis.yml index 89bdc0867..76d28791c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,46 +7,14 @@ jobs: include: - python: 3.7 env: TOXENV=lint - - python: 2.7 - env: TOXENV=py27 - - python: 3.5 - env: TOXENV=py35 - python: 3.6 env: TOXENV=py36 - python: 3.7 env: TOXENV=py37 - python: 3.8 env: TOXENV=py38 - - python: pypy - env: TOXENV=pypy - python: pypy3 env: TOXENV=pypy3 - - name: "Python 2.7 on Windows" - os: windows - language: shell - before_install: - - choco install python2 - - python --version - - python -m pip install --upgrade pip - - pip install --upgrade virtualenv wheel - - virtualenv $HOME/venv - - source $HOME/venv/Scripts/activate - env: - - TOXENV=py27 - - PATH=/c/Python27:/c/Python27/Scripts:$PATH - - name: "Python 3.5 on Windows" - os: windows - language: shell - before_install: - - choco install python --version 3.5.4 - - python --version - - python -m pip install --upgrade pip - - pip3 install --upgrade virtualenv wheel - - virtualenv $HOME/venv - - source $HOME/venv/Scripts/activate - env: - - TOXENV=py35 - - PATH=/c/Python35:/c/Python35/Scripts:$PATH - name: "Python 3.6 on Windows" os: windows language: shell @@ -54,8 +22,8 @@ jobs: - choco install python --version 3.6.7 - python --version - python -m pip install --upgrade pip - - pip3 install --upgrade virtualenv wheel - - virtualenv $HOME/venv + - python -m pip install --upgrade virtualenv wheel + - python -m virtualenv $HOME/venv - source $HOME/venv/Scripts/activate env: - TOXENV=py36 @@ -67,8 +35,8 @@ jobs: - choco install python --version 3.7.2 - python --version - python -m pip install --upgrade pip - - pip3 install --upgrade virtualenv wheel - - virtualenv $HOME/venv + - python -m pip install --upgrade virtualenv wheel + - python -m virtualenv $HOME/venv - source $HOME/venv/Scripts/activate env: - TOXENV=py37 @@ -80,8 +48,8 @@ jobs: - choco install python --version 3.8.0 - python --version - python -m pip install --upgrade pip - - pip3 install --upgrade virtualenv wheel - - virtualenv $HOME/venv + - python -m pip install --upgrade virtualenv wheel + - python -m virtualenv $HOME/venv - source $HOME/venv/Scripts/activate env: - TOXENV=py38 @@ -90,8 +58,7 @@ jobs: script: tox install: - - pip install tox - + - python -m pip install tox after_success: # Report coverage results to codecov.io diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 12d6c11bf..2f464d209 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -198,10 +198,10 @@ This configuration file setup the pytest-cov plugin and it is an additional depe It is possible to tests with some versions of python, to do this the command is: ```bash -tox -e py27,py35,pypy +tox -e py36,pypy3 ``` -Will run py.test with the python2.7, python3.5 and pypy interpreters, for example. +Will run py.test with the python3.6 and pypy3 interpreters, for example. ## Core Committer Guide diff --git a/README.md b/README.md index ac7feeec1..73f264d5b 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Did someone say features? * Cross-platform: Windows, Mac, and Linux are officially supported. * You don't have to know/write Python code to use Cookiecutter -* Works with Python 2.7, 3.5, 3.6, 3.7, 3.8, PyPy and PyPy3. -* Project templates can be in any programming language or markup format: - Python, JavaScript, Ruby, CoffeeScript, RST, Markdown, CSS, HTML, you name it. +* Works with Python 3.6, 3.7, 3.8 and PyPy3. +* Project templates can be in any programming language or markup format: + Python, JavaScript, Ruby, CoffeeScript, RST, Markdown, CSS, HTML, you name it. You can use multiple languages in the same project template. * Simple command line usage: diff --git a/cookiecutter/vcs.py b/cookiecutter/vcs.py index 417b4eaaa..402f75be4 100644 --- a/cookiecutter/vcs.py +++ b/cookiecutter/vcs.py @@ -6,11 +6,8 @@ import logging import os import subprocess +from shutil import which -try: - from shutil import which -except ImportError: - from whichcraft import which from cookiecutter.exceptions import ( RepositoryNotFound, diff --git a/cookiecutter/zipfile.py b/cookiecutter/zipfile.py index 17db00517..321cc91b3 100644 --- a/cookiecutter/zipfile.py +++ b/cookiecutter/zipfile.py @@ -4,16 +4,10 @@ import os import tempfile -from zipfile import ZipFile +from zipfile import BadZipFile, ZipFile import requests -try: - # BadZipfile was renamed to BadZipFile in Python 3.2. - from zipfile import BadZipFile -except ImportError: - from zipfile import BadZipfile as BadZipFile - from cookiecutter.exceptions import InvalidZipRepository from cookiecutter.prompt import read_repo_password from cookiecutter.utils import make_sure_path_exists, prompt_and_delete diff --git a/docs/installation.rst b/docs/installation.rst index 61f6d9984..44c0d841a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -18,7 +18,6 @@ You can install the Python binaries from `python.org =2.7.9 or Python 3 >=3.5. See the Python Packaging Authority's (PyPA) documentation `Requirements for Installing Packages `_ for full details. +``pip`` and ``setuptools`` now come with Python 3 >=3.6. See the Python Packaging Authority's (PyPA) documentation `Requirements for Installing Packages `_ for full details. Install cookiecutter @@ -70,7 +69,7 @@ At the command line: .. code-block:: bash - $ pip install --user cookiecutter + $ python3 -m pip install --user cookiecutter Or, if you do not have pip: @@ -133,6 +132,6 @@ Or with pip: .. code-block:: bash - $ pip install --upgrade cookiecutter + $ python3 -m pip install --upgrade cookiecutter Then you should be good to go. diff --git a/pyproject.toml b/pyproject.toml index 96b448390..9c25cb239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,4 +2,4 @@ skip-string-normalization = true exclude = '/(tests/hooks-abort-render/hooks|docs\/HelloCookieCutter1)/' line-length = 88 -target-version = ['py27'] +target-version = ['py36'] diff --git a/setup.py b/setup.py index a23afa0ba..7ae2614b3 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from setuptools import setup -version = "1.7.2" +version = "2.0.0" if sys.argv[-1] == 'publish': os.system('python setup.py sdist upload') @@ -58,9 +58,8 @@ package_dir={'cookiecutter': 'cookiecutter'}, entry_points={'console_scripts': ['cookiecutter = cookiecutter.__main__:main']}, include_package_data=True, - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', + python_requires='>=3.6', install_requires=requirements, - extras_require={':python_version<"3.3"': ['whichcraft>=0.4.0']}, license='BSD', zip_safe=False, classifiers=[ @@ -69,21 +68,26 @@ "Intended Audience :: Developers", "Natural Language :: English", "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "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", "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python", "Topic :: Software Development", ], - keywords=( - 'cookiecutter, Python, projects, project templates, Jinja2, ' - 'skeleton, scaffolding, project directory, setup.py, package, ' - 'packaging' - ), + keywords=[ + "cookiecutter", + "Python", + "projects", + "project templates", + "Jinja2", + "skeleton", + "scaffolding", + "project directory", + "package", + "packaging", + ], ) diff --git a/tox.ini b/tox.ini index 1c1c6114f..7d99c4eb4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,9 @@ [tox] envlist = lint - py27 - py35 py36 py37 py38 - pypy pypy3 minversion = 3.14.2 requires =