[Image-SIG] Suggestion to use tcl stubs when building PIL
Alexey Borzenkov
snaury at gmail.com
Mon Jul 27 13:10:34 CEST 2009
On Tue, Jul 14, 2009 at 11:48 PM, Sridhar
Ratnakumar<SridharR at activestate.com> wrote:
> Jeff Hobbs pointed out that using tcl stubs is the correct thing to do in
> order to ensure compatibility with different versions of Tcl/Tk libraries
> installed. Since this is not an issue with python.org's Python (whose 2.5
> version comes with Tcl/Tk 8.4), I do not consider this a severe issue,
> however, having this fixed will at least make PIL work against some of the
> custom Python installations (of which ActivePython is just one of them).
Actually, good idea. Here's a patch:
http://git.kitsu.ru/patched/pil.git?a=commitdiff;h=34b332238afbdd22a27f9e66905df60f8856e74c
(just ignore setup-df-mingw.py and setup-df.py)
Or here, if gmail doesn't screw it up:
diff --git a/Tk/tkImaging.c b/Tk/tkImaging.c
index 5e37d05..3ddace5 100644
--- a/Tk/tkImaging.c
+++ b/Tk/tkImaging.c
@@ -240,6 +240,12 @@ PyImagingPhotoGet(ClientData clientdata,
Tcl_Interp* interp,
void
TkImaging_Init(Tcl_Interp* interp)
{
+#ifdef USE_TCL_STUBS
+ Tcl_InitStubs(interp, TCL_VERSION, 0);
+#endif
+#ifdef USE_TK_STUBS
+ Tk_InitStubs(interp, TK_VERSION, 0);
+#endif
Tcl_CreateCommand(interp, "PyImagingPhoto", PyImagingPhotoPut,
(ClientData) 0, (Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand(interp, "PyImagingPhotoGet", PyImagingPhotoGet,
diff --git a/setup.py b/setup.py
index aee3d2d..2a64576 100644
--- a/setup.py
+++ b/setup.py
@@ -211,6 +211,7 @@ class pil_build_ext(build_ext):
class feature:
zlib = jpeg = tiff = freetype = tcl = tk = None
+ tclstub = tkstub = False
feature = feature()
if find_library_file(self, "z"):
@@ -250,11 +251,23 @@ class pil_build_ext(build_ext):
if _tkinter:
# the library names may vary somewhat (e.g. tcl84 or tcl8.4)
version = TCL_VERSION[0] + TCL_VERSION[2]
- if find_library_file(self, "tcl" + version):
+ if find_library_file(self, "tclstub" + version):
+ feature.tcl = "tclstub" + version
+ feature.tclstub = True
+ elif find_library_file(self, "tclstub" + TCL_VERSION):
+ feature.tcl = "tclstub" + TCL_VERSION
+ feature.tclstub = True
+ elif find_library_file(self, "tcl" + version):
feature.tcl = "tcl" + version
elif find_library_file(self, "tcl" + TCL_VERSION):
feature.tcl = "tcl" + TCL_VERSION
- if find_library_file(self, "tk" + version):
+ if find_library_file(self, "tkstub" + version):
+ feature.tk = "tkstub" + version
+ feature.tkstub = True
+ elif find_library_file(self, "tkstub" + TCL_VERSION):
+ feature.tk = "tkstub" + TCL_VERSION
+ feature.tkstub = True
+ elif find_library_file(self, "tk" + version):
feature.tk = "tk" + version
elif find_library_file(self, "tk" + TCL_VERSION):
feature.tk = "tk" + TCL_VERSION
@@ -326,9 +339,15 @@ class pil_build_ext(build_ext):
))
feature.tcl = feature.tk = 1 # mark as present
elif feature.tcl and feature.tk:
+ tkdefs = []
+ if feature.tclstub:
+ tkdefs.append(("USE_TCL_STUBS",None))
+ if feature.tkstub:
+ tkdefs.append(("USE_TK_STUBS",None))
exts.append(Extension(
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
- libraries=[feature.tcl, feature.tk]
+ libraries=[feature.tcl, feature.tk],
+ define_macros=tkdefs
))
if os.path.isfile("_imagingmath.c"):
More information about the Image-SIG
mailing list