From c48590bfbae83521271598f65c761ad5fd9e7ad1 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Sat, 29 Jun 2013 19:13:55 -0700 Subject: [PATCH 1/3] Fix ImportError during selftest. Remove path silliness. Also apply PEP8 and print Pillow version during test. --- selftest.py | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/selftest.py b/selftest.py index 26fdc2215..e3fa2dadb 100644 --- a/selftest.py +++ b/selftest.py @@ -1,26 +1,13 @@ # minimal sanity check from __future__ import print_function + +import sys +import os + +from PIL import Image, ImageDraw, ImageFilter, ImageMath + ROOT = "." -import os, sys - -# Path silliness. This selftest needs to be able to import itself, so -#it needs . in the path. However, since the compiled versions of the -#PIL bits are not in PIL, they're in dist, or build, or actually -#installed. In fact, importing from ./PIL is going to fail on any -#.c/so item. So. We remove it from the path, import all the PIL stuff -#from elsewhere, then pop the current directory back on the path so -#that we can import this and run the doctest - -del(sys.path[0]) - -from PIL import Image -from PIL import ImageDraw -from PIL import ImageFilter -from PIL import ImageMath - -sys.path.insert(0,ROOT) - try: Image.core.ping except ImportError as v: @@ -29,10 +16,12 @@ except ImportError as v: except AttributeError: pass + def _info(im): im.load() return im.format, im.mode, im.size + def testimage(): """ PIL lets you create in-memory images with various pixel types: @@ -174,6 +163,7 @@ def check_module(feature, module): else: print("---", feature, "support ok") + def check_codec(feature, codec): if codec + "_encoder" not in dir(Image.core): print("***", feature, "support not installed") @@ -187,8 +177,7 @@ if __name__ == "__main__": exit_status = 0 print("-"*68) - #print("PIL", Image.VERSION, "TEST SUMMARY ") - print("PIL TEST SUMMARY ") + print("Pillow", Image.PILLOW_VERSION, "TEST SUMMARY ") print("-"*68) print("Python modules loaded from", os.path.dirname(Image.__file__)) print("Binary modules loaded from", os.path.dirname(Image.core.__file__)) @@ -212,7 +201,8 @@ if __name__ == "__main__": print("-"*68) # use doctest to make sure the test program behaves as documented! - import doctest, selftest + import doctest + import selftest print("Running selftest:") status = doctest.testmod(selftest) if status[0]: @@ -222,4 +212,3 @@ if __name__ == "__main__": print("--- %s tests passed." % status[1]) sys.exit(exit_status) - From 9ef78fab61402bc470fd77fe3b6ca40b55eebd51 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Sun, 30 Jun 2013 11:37:31 -0700 Subject: [PATCH 2/3] Configure Travis to build inplace --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b8f23421..3eaa60e80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,6 @@ install: "sudo apt-get -qq install libfreetype6-dev liblcms1-dev libwebp-dev pyt script: - python setup.py clean - - python setup.py install + - python setup.py build_ext -i - python selftest.py - - python Tests/run.py --installed + - python Tests/run.py From c0a39b98fa4d05b0cbcc2789026b1400583ce140 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Sun, 30 Jun 2013 12:02:16 -0700 Subject: [PATCH 3/3] Use --inplace option To run Travis again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3eaa60e80..13fa00ac3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,6 @@ install: "sudo apt-get -qq install libfreetype6-dev liblcms1-dev libwebp-dev pyt script: - python setup.py clean - - python setup.py build_ext -i + - python setup.py build_ext --inplace - python selftest.py - python Tests/run.py