diff --git a/PIL/Image.py b/PIL/Image.py index 5d7331823..98de46cb0 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -53,7 +53,7 @@ try: # the "open" function to identify files, but you cannot load # them. Note that other modules should not refer to _imaging # directly; import Image and use the Image.core variable instead. - import _imaging as core + from . import _imaging as core except ImportError as v: core = _imaging_not_installed() if str(v)[:20] == "Module use of python" and warnings: diff --git a/PIL/ImageCms.py b/PIL/ImageCms.py index c41139b2b..3931f366c 100644 --- a/PIL/ImageCms.py +++ b/PIL/ImageCms.py @@ -82,7 +82,7 @@ VERSION = "0.1.0 pil" # --------------------------------------------------------------------. from PIL import Image -import _imagingcms +from . import _imagingcms core = _imagingcms diff --git a/PIL/ImageDraw.py b/PIL/ImageDraw.py index a1f931cbe..7e7759be1 100644 --- a/PIL/ImageDraw.py +++ b/PIL/ImageDraw.py @@ -313,13 +313,11 @@ def getdraw(im=None, hints=None): handler = None if not hints or "nicest" in hints: try: - import _imagingagg - handler = _imagingagg + from . import _imagingagg as handler except ImportError: pass if handler is None: - from PIL import ImageDraw2 - handler = ImageDraw2 + from PIL import ImageDraw2 as handler if im: im = handler.Draw(im) return im, handler diff --git a/PIL/ImageFont.py b/PIL/ImageFont.py index 97dafdd6a..73d6b3559 100644 --- a/PIL/ImageFont.py +++ b/PIL/ImageFont.py @@ -36,9 +36,7 @@ class _imagingft_not_installed: raise ImportError("The _imagingft C module is not installed") try: - import _imagingft - core = _imagingft - del _imagingft + from . import _imagingft as core except ImportError: core = _imagingft_not_installed() diff --git a/PIL/ImageGL.py b/PIL/ImageGL.py index 5c58b6ca9..147ddc3f0 100644 --- a/PIL/ImageGL.py +++ b/PIL/ImageGL.py @@ -17,7 +17,7 @@ # extensions.) ## -import _imaginggl +from . import _imaginggl ## # Texture factory. @@ -25,4 +25,4 @@ import _imaginggl class TextureFactory: pass # overwritten by the _imaginggl module -from _imaginggl import * +from ._imaginggl import * diff --git a/PIL/ImageMath.py b/PIL/ImageMath.py index 6548b0382..4f3c19273 100644 --- a/PIL/ImageMath.py +++ b/PIL/ImageMath.py @@ -16,7 +16,7 @@ # from PIL import Image -import _imagingmath +from . import _imagingmath import sys try: diff --git a/PIL/ImageTk.py b/PIL/ImageTk.py index feca9adce..c9b95df4e 100644 --- a/PIL/ImageTk.py +++ b/PIL/ImageTk.py @@ -28,9 +28,7 @@ try: import tkinter except ImportError: - import Tkinter - tkinter = Tkinter - del Tkinter + import Tkinter as tkinter from PIL import Image @@ -185,7 +183,7 @@ class PhotoImage: except tkinter.TclError as v: # activate Tkinter hook try: - import _imagingtk + from . import _imagingtk try: _imagingtk.tkinit(tk.interpaddr(), 1) except AttributeError: diff --git a/selftest.py b/selftest.py index f0cbe0ba4..167455f4e 100644 --- a/selftest.py +++ b/selftest.py @@ -182,12 +182,12 @@ if __name__ == "__main__": print("Python modules loaded from", os.path.dirname(Image.__file__)) print("Binary modules loaded from", os.path.dirname(Image.core.__file__)) print("-"*68) - check_module("PIL CORE", "_imaging") - check_module("TKINTER", "_imagingtk") + check_module("PIL CORE", "PIL._imaging") + check_module("TKINTER", "PIL._imagingtk") check_codec("JPEG", "jpeg") check_codec("ZLIB (PNG/ZIP)", "zip") - check_module("FREETYPE2", "_imagingft") - check_module("LITTLECMS", "_imagingcms") + check_module("FREETYPE2", "PIL._imagingft") + check_module("LITTLECMS", "PIL._imagingcms") print("-"*68) # use doctest to make sure the test program behaves as documented! diff --git a/setup.py b/setup.py index 4b9b080c1..f146c7ec5 100644 --- a/setup.py +++ b/setup.py @@ -290,7 +290,7 @@ class pil_build_ext(build_ext): defs.append(("WORDS_BIGENDIAN", None)) exts = [(Extension( - "_imaging", files, libraries=libs, define_macros=defs))] + "PIL._imaging", files, libraries=libs, define_macros=defs))] # # additional libraries @@ -300,19 +300,19 @@ class pil_build_ext(build_ext): if feature.freetype_version == 20: defs.append(("USE_FREETYPE_2_0", None)) exts.append(Extension( - "_imagingft", ["_imagingft.c"], libraries=["freetype"], + "PIL._imagingft", ["_imagingft.c"], libraries=["freetype"], define_macros=defs)) if os.path.isfile("_imagingtiff.c") and feature.tiff: exts.append(Extension( - "_imagingtiff", ["_imagingtiff.c"], libraries=["tiff"])) + "PIL._imagingtiff", ["_imagingtiff.c"], libraries=["tiff"])) if os.path.isfile("_imagingcms.c") and feature.lcms: extra = [] if sys.platform == "win32": extra.extend(["user32", "gdi32"]) exts.append(Extension( - "_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra)) + "PIL._imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra)) if sys.platform == "darwin": # locate Tcl/Tk frameworks @@ -332,16 +332,16 @@ class pil_build_ext(build_ext): break if frameworks: exts.append(Extension( - "_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], + "PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], extra_compile_args=frameworks, extra_link_args=frameworks)) feature.tcl = feature.tk = 1 # mark as present elif feature.tcl and feature.tk: exts.append(Extension( - "_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], + "PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], libraries=[feature.tcl, feature.tk])) if os.path.isfile("_imagingmath.c"): - exts.append(Extension("_imagingmath", ["_imagingmath.c"])) + exts.append(Extension("PIL._imagingmath", ["_imagingmath.c"])) self.extensions[:] = exts @@ -476,7 +476,7 @@ setup( "Programming Language :: Python :: 3.3", ], cmdclass={"build_ext": pil_build_ext}, - ext_modules=[Extension("_imaging", ["_imaging.c"])], + ext_modules=[Extension("PIL._imaging", ["_imaging.c"])], packages=find_packages(), scripts=glob.glob("Scripts/pil*.py"), keywords=("Imaging",),