From 7e991a804389d27834ff984d9a4cb5d8eea89576 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 8 Jul 2015 15:32:24 +1000 Subject: [PATCH 1/2] Allow Tcl/Tk frameworks to be disabled on OS X by setup arguments --- setup.py | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/setup.py b/setup.py index 34277b09c..69c65ddb9 100644 --- a/setup.py +++ b/setup.py @@ -571,32 +571,33 @@ class pil_build_ext(build_ext): exts.append(Extension( "PIL._webp", ["_webp.c"], libraries=libs, define_macros=defs)) - if sys.platform == "darwin": - # locate Tcl/Tk frameworks - frameworks = [] - framework_roots = [ - "/Library/Frameworks", - "/System/Library/Frameworks"] - for root in framework_roots: - if ( - os.path.exists(os.path.join(root, "Tcl.framework")) and - os.path.exists(os.path.join(root, "Tk.framework"))): - print("--- using frameworks at %s" % root) - frameworks = ["-framework", "Tcl", "-framework", "Tk"] - dir = os.path.join(root, "Tcl.framework", "Headers") - _add_directory(self.compiler.include_dirs, dir, 0) - dir = os.path.join(root, "Tk.framework", "Headers") - _add_directory(self.compiler.include_dirs, dir, 1) - break - if frameworks: + if feature.tcl and feature.tk: + if sys.platform == "darwin": + # locate Tcl/Tk frameworks + frameworks = [] + framework_roots = [ + "/Library/Frameworks", + "/System/Library/Frameworks"] + for root in framework_roots: + root_tcl = os.path.join(root, "Tcl.framework") + root_tk = os.path.join(root, "Tk.framework") + if (os.path.exists(root_tcl) and os.path.exists(root_tk)): + print("--- using frameworks at %s" % root) + frameworks = ["-framework", "Tcl", "-framework", "Tk"] + dir = os.path.join(root_tcl, "Headers") + _add_directory(self.compiler.include_dirs, dir, 0) + dir = os.path.join(root_tk, "Headers") + _add_directory(self.compiler.include_dirs, dir, 1) + break + if frameworks: + exts.append(Extension( + "PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], + extra_compile_args=frameworks, + extra_link_args=frameworks)) + else: exts.append(Extension( "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( - "PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], - libraries=[feature.tcl, feature.tk])) + libraries=[feature.tcl, feature.tk])) if os.path.isfile("_imagingmath.c"): exts.append(Extension("PIL._imagingmath", ["_imagingmath.c"])) From 60a3702fd52c7bb2fe2d67038754923dcbc766d1 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 8 Jul 2015 15:32:50 +1000 Subject: [PATCH 2/2] Flake8 fix --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 69c65ddb9..edfd24c41 100644 --- a/setup.py +++ b/setup.py @@ -464,7 +464,7 @@ class pil_build_ext(build_ext): if _find_library_file(self, "lcms2"): feature.lcms = "lcms2" elif _find_library_file(self, "lcms2_static"): - #alternate Windows name. + # alternate Windows name. feature.lcms = "lcms2_static" if _tkinter and _find_include_file(self, "tk.h"):