Allow Tcl/Tk frameworks to be disabled on OS X by setup arguments

This commit is contained in:
Andrew Murray 2015-07-08 15:32:24 +10:00
parent c0387ada42
commit 7e991a8043

View File

@ -571,6 +571,7 @@ class pil_build_ext(build_ext):
exts.append(Extension( exts.append(Extension(
"PIL._webp", ["_webp.c"], libraries=libs, define_macros=defs)) "PIL._webp", ["_webp.c"], libraries=libs, define_macros=defs))
if feature.tcl and feature.tk:
if sys.platform == "darwin": if sys.platform == "darwin":
# locate Tcl/Tk frameworks # locate Tcl/Tk frameworks
frameworks = [] frameworks = []
@ -578,22 +579,22 @@ class pil_build_ext(build_ext):
"/Library/Frameworks", "/Library/Frameworks",
"/System/Library/Frameworks"] "/System/Library/Frameworks"]
for root in framework_roots: for root in framework_roots:
if ( root_tcl = os.path.join(root, "Tcl.framework")
os.path.exists(os.path.join(root, "Tcl.framework")) and root_tk = os.path.join(root, "Tk.framework")
os.path.exists(os.path.join(root, "Tk.framework"))): if (os.path.exists(root_tcl) and os.path.exists(root_tk)):
print("--- using frameworks at %s" % root) print("--- using frameworks at %s" % root)
frameworks = ["-framework", "Tcl", "-framework", "Tk"] frameworks = ["-framework", "Tcl", "-framework", "Tk"]
dir = os.path.join(root, "Tcl.framework", "Headers") dir = os.path.join(root_tcl, "Headers")
_add_directory(self.compiler.include_dirs, dir, 0) _add_directory(self.compiler.include_dirs, dir, 0)
dir = os.path.join(root, "Tk.framework", "Headers") dir = os.path.join(root_tk, "Headers")
_add_directory(self.compiler.include_dirs, dir, 1) _add_directory(self.compiler.include_dirs, dir, 1)
break break
if frameworks: if frameworks:
exts.append(Extension( exts.append(Extension(
"PIL._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,
feature.tcl = feature.tk = 1 # mark as present extra_link_args=frameworks))
elif feature.tcl and feature.tk: else:
exts.append(Extension( exts.append(Extension(
"PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"], "PIL._imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
libraries=[feature.tcl, feature.tk])) libraries=[feature.tcl, feature.tk]))