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
|
||||
# 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:
|
||||
|
|
|
@ -82,7 +82,7 @@ VERSION = "0.1.0 pil"
|
|||
# --------------------------------------------------------------------.
|
||||
|
||||
from PIL import Image
|
||||
import _imagingcms
|
||||
from . import _imagingcms
|
||||
|
||||
core = _imagingcms
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#
|
||||
|
||||
from PIL import Image
|
||||
import _imagingmath
|
||||
from . import _imagingmath
|
||||
import sys
|
||||
|
||||
try:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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!
|
||||
|
|
16
setup.py
16
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",),
|
||||
|
|
Loading…
Reference in New Issue
Block a user