Skip to content

Commit

Permalink
Drop support for Python 2, Python 3.4 and 3.5
Browse files Browse the repository at this point in the history
Python 2 has been EOL for since Jan 1, 2020, Python 3.4 has been EOL
since Mar 18, 2019 and Python 3.5 has been EOL since Sep 13, 2020.

Drop obsolete 'from __future__' imports, drop obsolete conditionals due
to Python 2 vs. 3 differences.
  • Loading branch information
tjanez committed Sep 14, 2021
1 parent ad2e58f commit d956dec
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ Use Pythonz to download and build a Python vm

`usage: pew install [options] version`

To install Python3.5.0
To install Python3.8.0

`pew install 3.5.0`
`pew install 3.8.0`

To install Pypy:

Expand Down Expand Up @@ -382,15 +382,15 @@ To run individual test scripts, run from the top level directory of the reposito

To run tests under a single version of Python, specify the appropriate environment when running `tox`:

`tox -e py27`
`tox -e py38`

Combine the two modes to run specific tests with a single version of Python:

`tox -e py27 tests/test_setproject.py`
`tox -e py38 tests/test_setproject.py`

You can also filter them:

`tox -e py34 -- -k workon`
`tox -e py38 -- -k workon`

Add new tests by modifying an existing file or creating new script in the tests directory.

Expand Down
2 changes: 0 additions & 2 deletions pew/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from __future__ import absolute_import

from . import pew
__all__ = ['pew']
12 changes: 2 additions & 10 deletions pew/_print_utils.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
from __future__ import division, print_function

import os
from functools import partial
from math import ceil
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest
try:
from shutil import get_terminal_size
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
from itertools import zip_longest
from shutil import get_terminal_size

SEP = ' '
L = len(SEP)
Expand Down
21 changes: 3 additions & 18 deletions pew/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,16 @@
from collections import namedtuple
from functools import partial, wraps
from pathlib import Path
from tempfile import NamedTemporaryFile as _ntf
try:
from shutil import which
except ImportError:
from shutilwhich import which
from tempfile import NamedTemporaryFile
from shutil import which

py2 = sys.version_info[0] == 2
windows = sys.platform == 'win32'

if py2 or windows:
if windows:
locale.setlocale(locale.LC_CTYPE, '')

encoding = locale.getlocale()[1] or 'ascii'

if py2:
@wraps(_ntf)
def NamedTemporaryFile(mode):
return getwriter(encoding)(_ntf(mode))

def to_unicode(x):
return x.decode(encoding)
else:
NamedTemporaryFile = _ntf
to_unicode = str

def check_path():
parent = os.path.dirname
return parent(parent(which('python'))) == os.environ['VIRTUAL_ENV']
Expand Down
14 changes: 3 additions & 11 deletions pew/pew.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function, absolute_import, unicode_literals

import os
import sys
import argparse
Expand All @@ -10,10 +8,7 @@
from subprocess import CalledProcessError
from pathlib import Path

try:
from shutil import get_terminal_size
except ImportError:
from backports.shutil_get_terminal_size import get_terminal_size
from shutil import get_terminal_size

windows = sys.platform == 'win32'

Expand Down Expand Up @@ -46,12 +41,9 @@ def ListPythons():
import shellingham

from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
check_path, temp_environ, NamedTemporaryFile, to_unicode)
check_path, temp_environ, NamedTemporaryFile)
from pew._print_utils import print_virtualenvs

if sys.version_info[0] == 2:
input = raw_input

err = partial(print, file=sys.stderr)

if windows:
Expand Down Expand Up @@ -170,7 +162,7 @@ def fork_bash(env, cwd):
with NamedTemporaryFile('w+') as rcfile:
with bashrcpath.open() as bashrc:
rcfile.write(bashrc.read())
rcfile.write('\nexport PATH="' + to_unicode(compute_path(env)) + '"')
rcfile.write('\nexport PATH="' + compute_path(env) + '"')
rcfile.flush()
return fork_shell(env, ['bash', '--rcfile', rcfile.name], cwd)
else:
Expand Down
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ def run(self):
'virtualenv>=1.11', 'virtualenv-clone>=0.2.5', 'setuptools>=17.1'
],
extras_require={
':python_version=="2.7"': [
'pathlib', 'backports.shutil_get_terminal_size', 'shutilwhich'
],
':sys_platform=="win32"': [
'shellingham'
],
Expand All @@ -83,7 +80,6 @@ def run(self):
entry_points={
'console_scripts': ['pew = pew.pew:pew']},
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Intended Audience :: Developers',
'Environment :: Console']
Expand Down
5 changes: 1 addition & 4 deletions tests/test_print_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
get_best_columns_number,
columnize,
)
try:
from unittest.mock import patch
except ImportError:
from mock import patch
from unittest.mock import patch


def test_get_rows():
Expand Down
23 changes: 4 additions & 19 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
try:
from tempfile import TemporaryDirectory
except ImportError:
from shutil import rmtree
from contextlib import contextmanager
from tempfile import mkdtemp

@contextmanager
def TemporaryDirectory():
tmpdir = mkdtemp()
yield tmpdir
rmtree(tmpdir)

try:
from urllib.request import urlopen
from urllib.error import URLError
except ImportError:
from urllib import urlopen
URLError = IOError
from tempfile import TemporaryDirectory

from urllib.request import urlopen
from urllib.error import URLError


import functools
Expand Down
9 changes: 1 addition & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[tox]
skip_missing_interpreters=True
envlist = py{27,34,35,36,37,38,39}-{linux,windows}, pypy
envlist = py{36,37,38,39}-{linux,windows}, pypy

[gh-actions]
python =
2.7: py27
3.4: py34
3.5: py35
3.6: py36
3.7: py37
3.8: py38
Expand All @@ -23,10 +20,6 @@ passenv = CI HOME
commands = py.test -rw []
deps =
-r{toxinidir}/requirements.txt
py27: pathlib>=1.0.1
py27: mock
py27: backports.shutil_get_terminal_size
py27: shutilwhich
pypy: shutilwhich
pypy: pathlib>=1.0.1
pypy: mock
Expand Down

0 comments on commit d956dec

Please sign in to comment.