Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for EOL Python 2.7 #4109

Merged
merged 28 commits into from Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
af770a6
Drop support for EOL Python 2.7
hugovk Sep 26, 2019
538d9e2
Upgrade Python syntax with pyupgrade --py3-plus
hugovk Sep 30, 2019
74d2767
Remove duplicate line
hugovk Oct 2, 2019
810b61e
Reinstate and simplify parallel auto-detection
hugovk Oct 2, 2019
7e3156e
Updated IFDRational operators
radarhere Oct 7, 2019
865b17d
Remove Python 2-compatibility code
hugovk Oct 7, 2019
4382413
Remove redundant bytearray
hugovk Oct 7, 2019
6cd99fc
Merge branch 'master' into rm-2.7
radarhere Oct 8, 2019
84e53e3
Simplify using subprocess.DEVNULL
hugovk Oct 8, 2019
3a34081
Simplify temporary directory cleanup
hugovk Oct 8, 2019
0caa48b
Remove redundant __future__ from docs
hugovk Oct 8, 2019
e118de9
Remove redundant __ne__ method
hugovk Oct 8, 2019
3e24c5f
Replace isStringType(t) with isinstance(t, str)
hugovk Oct 8, 2019
4140cd8
Merge branch 'master' into rm-2.7
radarhere Oct 12, 2019
3e3a737
Merge remote-tracking branch 'upstream/master' into rm-2.7
hugovk Oct 12, 2019
23fa3c6
Remove outdated OS scripts, point docs to Dockerfiles
hugovk Oct 12, 2019
3dac6e2
Replace ImageShow.which() with stdlib
hugovk Oct 12, 2019
28ff798
Merge branch 'master' into rm-2.7
hugovk Oct 15, 2019
40133cf
Merge branch 'master' into rm-2.7
hugovk Oct 26, 2019
cc63f66
Merge remote-tracking branch 'upstream/master' into rm-2.7
hugovk Nov 1, 2019
b4f93cf
Upgrade Python syntax with pyupgrade --py3-plus
hugovk Nov 1, 2019
6f88d8d
black --target-version py35
hugovk Nov 2, 2019
58e6d12
In Python 3, 'next' is renamed to '__next__'
hugovk Nov 3, 2019
5006401
Merge branch 'master' into rm-2.7
hugovk Nov 3, 2019
24b8501
Remove handling for pre-3.3 wide/narrow builds
hugovk Nov 3, 2019
12a7259
Merge remote-tracking branch 'upstream/master' into rm-2.7
hugovk Nov 16, 2019
e5486b4
Merge remote-tracking branch 'upstream/master' into rm-2.7
hugovk Nov 18, 2019
a949d78
Merge branch 'master' into rm-2.7
hugovk Nov 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions .appveyor.yml
Expand Up @@ -40,11 +40,6 @@ install:
- xcopy c:\pillow-depends\*.tar.gz c:\pillow\winbuild\
- xcopy /s c:\pillow-depends\test_images\* c:\pillow\tests\images
- cd c:\pillow\winbuild\
- ps: |
if ($env:PYTHON -eq "c:/vp/pypy2")
{
c:\pillow\winbuild\appveyor_install_pypy2.cmd
}
- ps: |
if ($env:PYTHON -eq "c:/vp/pypy3")
{
Expand Down
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Expand Up @@ -9,14 +9,14 @@ Please send a pull request to the master branch. Please include [documentation](
- Fork the Pillow repository.
- Create a branch from master.
- Develop bug fixes, features, tests, etc.
- Run the test suite on Python 2.7 and 3.x. You can enable [Travis CI](https://travis-ci.org/profile/) and [AppVeyor](https://ci.appveyor.com/projects/new) on your repo to catch test failures prior to the pull request, and [Codecov](https://codecov.io/gh) to see if the changed code is covered by tests.
- Run the test suite. You can enable [Travis CI](https://travis-ci.org/profile/) and [AppVeyor](https://ci.appveyor.com/projects/new) on your repo to catch test failures prior to the pull request, and [Codecov](https://codecov.io/gh) to see if the changed code is covered by tests.
- Create a pull request to pull the changes from your branch to the Pillow master.

### Guidelines

- Separate code commits from reformatting commits.
- Provide tests for any newly added code.
- Follow PEP8.
- Follow PEP 8.
- When committing only documentation changes please include [ci skip] in the commit message to avoid running tests on Travis-CI and AppVeyor.

## Reporting Issues
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -6,8 +6,8 @@ notifications:
irc: "chat.freenode.net#pil"

# Run fast lint first to get fast feedback.
# Run slow PyPy* next, to give them a headstart and reduce waiting time.
# Run latest 3.x and 2.x next, to get quick compatibility results.
# Run slow PyPy next, to give it a headstart and reduce waiting time.
# Run latest 3.x next, to get quick compatibility results.
# Then run the remainder, with fastest Docker jobs last.

matrix:
Expand Down
10 changes: 3 additions & 7 deletions .travis/after_success.sh
Expand Up @@ -11,16 +11,12 @@ coveralls-lcov -v -n coverage.filtered.info > coverage.c.json

coverage report
pip install codecov
if [[ $TRAVIS_PYTHON_VERSION != "2.7_with_system_site_packages" ]]; then
# Not working here. Just skip it, it's being removed soon.
pip install coveralls-merge
coveralls-merge coverage.c.json
fi
pip install coveralls-merge
coveralls-merge coverage.c.json
codecov

if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] && [ "$DOCKER" == "" ]; then
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ] && [ "$DOCKER" == "" ]; then
# Coverage and quality reports on just the latest diff.
# (Installation is very slow on Py3, so just do it for Py2.)
depends/diffcover-install.sh
depends/diffcover-run.sh
fi
4 changes: 2 additions & 2 deletions .travis/install.sh
Expand Up @@ -20,8 +20,8 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.* ]]; then
pip install pyqt5
fi

# docs only on Python 2.7
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then pip install -r requirements.txt ; fi
# docs only on Python 3.7
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ]; then pip install -r requirements.txt ; fi

# webp
pushd depends && ./install_webp.sh && popd
Expand Down
2 changes: 1 addition & 1 deletion .travis/test.sh
Expand Up @@ -5,4 +5,4 @@ set -e
python -m pytest -v -x --cov PIL --cov-report term Tests

# Docs
if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then make doccheck; fi
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ]; then make doccheck; fi
36 changes: 18 additions & 18 deletions Makefile
Expand Up @@ -3,7 +3,7 @@
.DEFAULT_GOAL := release-test

clean:
python setup.py clean
python3 setup.py clean
rm src/PIL/*.so || true
rm -r build || true
find . -name __pycache__ | xargs rm -r || true
Expand All @@ -15,8 +15,8 @@ co:
done

coverage:
python selftest.py
python setup.py test
python3 selftest.py
python3 setup.py test
rm -r htmlcov || true
coverage report

Expand All @@ -30,7 +30,7 @@ doccheck:
$(MAKE) -C docs linkcheck || true

docserve:
cd docs/_build/html && python -mSimpleHTTPServer 2> /dev/null&
cd docs/_build/html && python3 -mSimpleHTTPServer 2> /dev/null&

help:
@echo "Welcome to Pillow development. Please use \`make <target>\` where <target> is one of"
Expand All @@ -50,22 +50,22 @@ help:
@echo " upload-test build and upload sdists to test.pythonpackages.com"

inplace: clean
python setup.py develop build_ext --inplace
python3 setup.py develop build_ext --inplace

install:
python setup.py install
python selftest.py
python3 setup.py install
python3 selftest.py

install-coverage:
CFLAGS="-coverage" python setup.py build_ext install
python selftest.py
CFLAGS="-coverage" python3 setup.py build_ext install
python3 selftest.py

debug:
# make a debug version if we don't have a -dbg python. Leaves in symbols
# for our stuff, kills optimization, and redirects to dev null so we
# see any build failures.
make clean > /dev/null
CFLAGS='-g -O0' python setup.py build_ext install > /dev/null
CFLAGS='-g -O0' python3 setup.py build_ext install > /dev/null

install-req:
pip install -r requirements.txt
Expand All @@ -76,17 +76,17 @@ install-venv:

release-test:
$(MAKE) install-req
python setup.py develop
python selftest.py
python -m pytest Tests
python setup.py install
python -m pytest -qq
python3 setup.py develop
python3 selftest.py
python3 -m pytest Tests
python3 setup.py install
python3 -m pytest -qq
check-manifest
pyroma .
viewdoc

sdist:
python setup.py sdist --format=gztar
python3 setup.py sdist --format=gztar

test:
pytest -qq
Expand All @@ -97,10 +97,10 @@ upload-test:
# username:
# password:
# repository = http://test.pythonpackages.com
python setup.py sdist --format=gztar upload -r test
python3 setup.py sdist --format=gztar upload -r test

upload:
python setup.py sdist --format=gztar upload
python3 setup.py sdist --format=gztar upload

readme:
viewdoc
3 changes: 0 additions & 3 deletions Tests/check_imaging_leaks.py
@@ -1,7 +1,4 @@
#!/usr/bin/env python

from __future__ import division

from PIL import Image

from .helper import PillowTestCase, is_win32, unittest
Expand Down
2 changes: 0 additions & 2 deletions Tests/createfontdatachunk.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function

import base64
import os

Expand Down
45 changes: 22 additions & 23 deletions Tests/helper.py
@@ -1,7 +1,6 @@
"""
Helper functions.
"""
from __future__ import print_function

import logging
import os
Expand All @@ -12,7 +11,6 @@
from io import BytesIO

from PIL import Image, ImageMath
from PIL._util import py3

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -76,31 +74,38 @@ def delete_tempfile(self, path):
def assert_deep_equal(self, a, b, msg=None):
try:
self.assertEqual(
len(a), len(b), msg or "got length %s, expected %s" % (len(a), len(b))
len(a),
len(b),
msg or "got length {}, expected {}".format(len(a), len(b)),
)
self.assertTrue(
all(x == y for x, y in zip(a, b)), msg or "got %s, expected %s" % (a, b)
all(x == y for x, y in zip(a, b)),
msg or "got {}, expected {}".format(a, b),
)
except Exception:
self.assertEqual(a, b, msg)

def assert_image(self, im, mode, size, msg=None):
if mode is not None:
self.assertEqual(
im.mode, mode, msg or "got mode %r, expected %r" % (im.mode, mode)
im.mode,
mode,
msg or "got mode {!r}, expected {!r}".format(im.mode, mode),
)

if size is not None:
self.assertEqual(
im.size, size, msg or "got size %r, expected %r" % (im.size, size)
im.size,
size,
msg or "got size {!r}, expected {!r}".format(im.size, size),
)

def assert_image_equal(self, a, b, msg=None):
self.assertEqual(
a.mode, b.mode, msg or "got mode %r, expected %r" % (a.mode, b.mode)
a.mode, b.mode, msg or "got mode {!r}, expected {!r}".format(a.mode, b.mode)
)
self.assertEqual(
a.size, b.size, msg or "got size %r, expected %r" % (a.size, b.size)
a.size, b.size, msg or "got size {!r}, expected {!r}".format(a.size, b.size)
)
if a.tobytes() != b.tobytes():
if HAS_UPLOADER:
Expand All @@ -121,10 +126,10 @@ def assert_image_equal_tofile(self, a, filename, msg=None, mode=None):
def assert_image_similar(self, a, b, epsilon, msg=None):
epsilon = float(epsilon)
self.assertEqual(
a.mode, b.mode, msg or "got mode %r, expected %r" % (a.mode, b.mode)
a.mode, b.mode, msg or "got mode {!r}, expected {!r}".format(a.mode, b.mode)
)
self.assertEqual(
a.size, b.size, msg or "got size %r, expected %r" % (a.size, b.size)
a.size, b.size, msg or "got size {!r}, expected {!r}".format(a.size, b.size)
)

a, b = convert_to_comparable(a, b)
Expand Down Expand Up @@ -216,12 +221,12 @@ def tempfile(self, template):

def open_withImagemagick(self, f):
if not imagemagick_available():
raise IOError()
raise OSError()

outfile = self.tempfile("temp.png")
if command_succeeds([IMCONVERT, f, outfile]):
return Image.open(outfile)
raise IOError()
raise OSError()


@unittest.skipIf(sys.platform.startswith("win32"), "requires Unix or macOS")
Expand Down Expand Up @@ -264,11 +269,6 @@ def _test_leak(self, core):

# helpers

if not py3:
# Remove DeprecationWarning in Python 3
PillowTestCase.assertRaisesRegex = PillowTestCase.assertRaisesRegexp
PillowTestCase.assertRegex = PillowTestCase.assertRegexpMatches


def fromstring(data):
return Image.open(BytesIO(data))
Expand Down Expand Up @@ -306,11 +306,10 @@ def command_succeeds(cmd):
Runs the command, which must be a list of strings. Returns True if the
command succeeds, or False if an OSError was raised by subprocess.Popen.
"""
with open(os.devnull, "wb") as f:
try:
subprocess.call(cmd, stdout=f, stderr=subprocess.STDOUT)
except OSError:
return False
try:
subprocess.call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
except OSError:
return False
return True


Expand Down Expand Up @@ -373,7 +372,7 @@ def distro():
return line.strip().split("=")[1]


class cached_property(object):
class cached_property:
def __init__(self, func):
self.func = func

Expand Down
2 changes: 0 additions & 2 deletions Tests/import_all.py
@@ -1,5 +1,3 @@
from __future__ import print_function

import glob
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions Tests/make_hash.py
@@ -1,7 +1,5 @@
# brute-force search for access descriptor hash table

from __future__ import print_function

modes = [
"1",
"L",
Expand Down
4 changes: 1 addition & 3 deletions Tests/test_bmp_reference.py
@@ -1,5 +1,3 @@
from __future__ import print_function

import os

from PIL import Image
Expand Down Expand Up @@ -109,4 +107,4 @@ def get_compare(f):
os.path.join(base, "g", "pal4rle.bmp"),
)
if f not in unsupported:
self.fail("Unsupported Image %s: %s" % (f, msg))
self.fail("Unsupported Image {}: {}".format(f, msg))
2 changes: 0 additions & 2 deletions Tests/test_color_lut.py
@@ -1,5 +1,3 @@
from __future__ import division

from array import array

from PIL import Image, ImageFilter
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_core_resources.py
@@ -1,5 +1,3 @@
from __future__ import division, print_function

import sys

from PIL import Image
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_features.py
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import io

from PIL import features
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_eps.py
Expand Up @@ -91,7 +91,7 @@ def test_file_object(self):
def test_iobase_object(self):
# issue 479
with Image.open(file1) as image1:
with io.open(self.tempfile("temp_iobase.eps"), "wb") as fh:
with open(self.tempfile("temp_iobase.eps"), "wb") as fh:
image1.save(fh, "EPS")

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
Expand Down