mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Merge pull request #88 from cgohlke/patch-9
Install extension modules into the PIL package directory
This commit is contained in:
commit
2751d8a931
|
@ -53,7 +53,7 @@ try:
|
||||||
# the "open" function to identify files, but you cannot load
|
# the "open" function to identify files, but you cannot load
|
||||||
# them. Note that other modules should not refer to _imaging
|
# them. Note that other modules should not refer to _imaging
|
||||||
# directly; import Image and use the Image.core variable instead.
|
# directly; import Image and use the Image.core variable instead.
|
||||||
import _imaging as core
|
from . import _imaging as core
|
||||||
except ImportError as v:
|
except ImportError as v:
|
||||||
core = _imaging_not_installed()
|
core = _imaging_not_installed()
|
||||||
if str(v)[:20] == "Module use of python" and warnings:
|
if str(v)[:20] == "Module use of python" and warnings:
|
||||||
|
|
|
@ -82,7 +82,7 @@ VERSION = "0.1.0 pil"
|
||||||
# --------------------------------------------------------------------.
|
# --------------------------------------------------------------------.
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import _imagingcms
|
from . import _imagingcms
|
||||||
|
|
||||||
core = _imagingcms
|
core = _imagingcms
|
||||||
|
|
||||||
|
|
|
@ -313,13 +313,11 @@ def getdraw(im=None, hints=None):
|
||||||
handler = None
|
handler = None
|
||||||
if not hints or "nicest" in hints:
|
if not hints or "nicest" in hints:
|
||||||
try:
|
try:
|
||||||
import _imagingagg
|
from . import _imagingagg as handler
|
||||||
handler = _imagingagg
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
if handler is None:
|
if handler is None:
|
||||||
from PIL import ImageDraw2
|
from PIL import ImageDraw2 as handler
|
||||||
handler = ImageDraw2
|
|
||||||
if im:
|
if im:
|
||||||
im = handler.Draw(im)
|
im = handler.Draw(im)
|
||||||
return im, handler
|
return im, handler
|
||||||
|
|
|
@ -36,9 +36,7 @@ class _imagingft_not_installed:
|
||||||
raise ImportError("The _imagingft C module is not installed")
|
raise ImportError("The _imagingft C module is not installed")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _imagingft
|
from . import _imagingft as core
|
||||||
core = _imagingft
|
|
||||||
del _imagingft
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
core = _imagingft_not_installed()
|
core = _imagingft_not_installed()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# extensions.)
|
# extensions.)
|
||||||
##
|
##
|
||||||
|
|
||||||
import _imaginggl
|
from . import _imaginggl
|
||||||
|
|
||||||
##
|
##
|
||||||
# Texture factory.
|
# Texture factory.
|
||||||
|
@ -25,4 +25,4 @@ import _imaginggl
|
||||||
class TextureFactory:
|
class TextureFactory:
|
||||||
pass # overwritten by the _imaginggl module
|
pass # overwritten by the _imaginggl module
|
||||||
|
|
||||||
from _imaginggl import *
|
from ._imaginggl import *
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import _imagingmath
|
from . import _imagingmath
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -28,9 +28,7 @@
|
||||||
try:
|
try:
|
||||||
import tkinter
|
import tkinter
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import Tkinter
|
import Tkinter as tkinter
|
||||||
tkinter = Tkinter
|
|
||||||
del Tkinter
|
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
@ -185,7 +183,7 @@ class PhotoImage:
|
||||||
except tkinter.TclError as v:
|
except tkinter.TclError as v:
|
||||||
# activate Tkinter hook
|
# activate Tkinter hook
|
||||||
try:
|
try:
|
||||||
import _imagingtk
|
from . import _imagingtk
|
||||||
try:
|
try:
|
||||||
_imagingtk.tkinit(tk.interpaddr(), 1)
|
_imagingtk.tkinit(tk.interpaddr(), 1)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -182,12 +182,12 @@ if __name__ == "__main__":
|
||||||
print("Python modules loaded from", os.path.dirname(Image.__file__))
|
print("Python modules loaded from", os.path.dirname(Image.__file__))
|
||||||
print("Binary modules loaded from", os.path.dirname(Image.core.__file__))
|
print("Binary modules loaded from", os.path.dirname(Image.core.__file__))
|
||||||
print("-"*68)
|
print("-"*68)
|
||||||
check_module("PIL CORE", "_imaging")
|
check_module("PIL CORE", "PIL._imaging")
|
||||||
check_module("TKINTER", "_imagingtk")
|
check_module("TKINTER", "PIL._imagingtk")
|
||||||
check_codec("JPEG", "jpeg")
|
check_codec("JPEG", "jpeg")
|
||||||
check_codec("ZLIB (PNG/ZIP)", "zip")
|
check_codec("ZLIB (PNG/ZIP)", "zip")
|
||||||
check_module("FREETYPE2", "_imagingft")
|
check_module("FREETYPE2", "PIL._imagingft")
|
||||||
check_module("LITTLECMS", "_imagingcms")
|
check_module("LITTLECMS", "PIL._imagingcms")
|
||||||
print("-"*68)
|
print("-"*68)
|
||||||
|
|
||||||
# use doctest to make sure the test program behaves as documented!
|
# use doctest to make sure the test program behaves as documented!
|
||||||
|
|
16
setup.py
16
setup.py
|
@ -290,7 +290,7 @@ class pil_build_ext(build_ext):
|
||||||
defs.append(("WORDS_BIGENDIAN", None))
|
defs.append(("WORDS_BIGENDIAN", None))
|
||||||
|
|
||||||
exts = [(Extension(
|
exts = [(Extension(
|
||||||
"_imaging", files, libraries=libs, define_macros=defs))]
|
"PIL._imaging", files, libraries=libs, define_macros=defs))]
|
||||||
|
|
||||||
#
|
#
|
||||||
# additional libraries
|
# additional libraries
|
||||||
|
@ -300,19 +300,19 @@ class pil_build_ext(build_ext):
|
||||||
if feature.freetype_version == 20:
|
if feature.freetype_version == 20:
|
||||||
defs.append(("USE_FREETYPE_2_0", None))
|
defs.append(("USE_FREETYPE_2_0", None))
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
"_imagingft", ["_imagingft.c"], libraries=["freetype"],
|
"PIL._imagingft", ["_imagingft.c"], libraries=["freetype"],
|
||||||
define_macros=defs))
|
define_macros=defs))
|
||||||
|
|
||||||
if os.path.isfile("_imagingtiff.c") and feature.tiff:
|
if os.path.isfile("_imagingtiff.c") and feature.tiff:
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
"_imagingtiff", ["_imagingtiff.c"], libraries=["tiff"]))
|
"PIL._imagingtiff", ["_imagingtiff.c"], libraries=["tiff"]))
|
||||||
|
|
||||||
if os.path.isfile("_imagingcms.c") and feature.lcms:
|
if os.path.isfile("_imagingcms.c") and feature.lcms:
|
||||||
extra = []
|
extra = []
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
extra.extend(["user32", "gdi32"])
|
extra.extend(["user32", "gdi32"])
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
"_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra))
|
"PIL._imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra))
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
# locate Tcl/Tk frameworks
|
# locate Tcl/Tk frameworks
|
||||||
|
@ -332,16 +332,16 @@ class pil_build_ext(build_ext):
|
||||||
break
|
break
|
||||||
if frameworks:
|
if frameworks:
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
"PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
||||||
extra_compile_args=frameworks, extra_link_args=frameworks))
|
extra_compile_args=frameworks, extra_link_args=frameworks))
|
||||||
feature.tcl = feature.tk = 1 # mark as present
|
feature.tcl = feature.tk = 1 # mark as present
|
||||||
elif feature.tcl and feature.tk:
|
elif feature.tcl and feature.tk:
|
||||||
exts.append(Extension(
|
exts.append(Extension(
|
||||||
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
"PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
||||||
libraries=[feature.tcl, feature.tk]))
|
libraries=[feature.tcl, feature.tk]))
|
||||||
|
|
||||||
if os.path.isfile("_imagingmath.c"):
|
if os.path.isfile("_imagingmath.c"):
|
||||||
exts.append(Extension("_imagingmath", ["_imagingmath.c"]))
|
exts.append(Extension("PIL._imagingmath", ["_imagingmath.c"]))
|
||||||
|
|
||||||
self.extensions[:] = exts
|
self.extensions[:] = exts
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ setup(
|
||||||
"Programming Language :: Python :: 3.3",
|
"Programming Language :: Python :: 3.3",
|
||||||
],
|
],
|
||||||
cmdclass={"build_ext": pil_build_ext},
|
cmdclass={"build_ext": pil_build_ext},
|
||||||
ext_modules=[Extension("_imaging", ["_imaging.c"])],
|
ext_modules=[Extension("PIL._imaging", ["_imaging.c"])],
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
scripts=glob.glob("Scripts/pil*.py"),
|
scripts=glob.glob("Scripts/pil*.py"),
|
||||||
keywords=("Imaging",),
|
keywords=("Imaging",),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user