From f92604b590ef1801682584aa79571e0492101660 Mon Sep 17 00:00:00 2001 From: lambdalisue Date: Wed, 15 Jul 2015 14:02:47 +0900 Subject: [PATCH] Fix RuntimeError: tk.h version (8.6) doesn't match libtk.a version (8.5) The problem was that CPPFLAGS and LDFLAGS for brewed Tk were specified to environment variable but Python (seems) prefer the CPPFLAGS in arguments specified to './configure', mean "-I#{MacOS.sdk_path}/usr/include" version is used. This commit would fix issue #18657 --- Library/Formula/python.rb | 22 ++++++++++++++-------- Library/Formula/python3.rb | 23 +++++++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb index 3b4131282639..a6dd833067ea 100644 --- a/Library/Formula/python.rb +++ b/Library/Formula/python.rb @@ -101,18 +101,20 @@ def install args << "--without-gcc" if ENV.compiler == :clang + cflags = [] + ldflags = [] + cppflags = [] + unless MacOS::CLT.installed? # Help Python's build system (setuptools/pip) to build things on Xcode-only systems # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) - cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" - ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" - args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib + cflags << "-isysroot #{MacOS.sdk_path}" + ldflags << "-isysroot #{MacOS.sdk_path}" + cppflags << "-I#{MacOS.sdk_path}/usr/include" # find zlib # For the Xlib.h, Python needs this header dir with the system Tk if build.without? "tcl-tk" - cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" + cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" end - args << cflags - args << ldflags end # Avoid linking to libgcc https://code.activestate.com/lists/python-dev/112195/ @@ -147,10 +149,14 @@ def install if build.with? "tcl-tk" tcl_tk = Formula["homebrew/dupes/tcl-tk"].opt_prefix - ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" - ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" + cppflags << "-I#{tcl_tk}/include" + ldflags << "-L#{tcl_tk}/lib" end + args << "CFLAGS=#{cflags.join(' ')}" unless cflags.empty? + args << "LDFLAGS=#{ldflags.join(' ')}" unless ldflags.empty? + args << "CPPFLAGS=#{cppflags.join(' ')}" unless cppflags.empty? + system "./configure", *args # HAVE_POLL is "broken" on OS X. See: diff --git a/Library/Formula/python3.rb b/Library/Formula/python3.rb index 85401e1f53e0..217d473c02a3 100644 --- a/Library/Formula/python3.rb +++ b/Library/Formula/python3.rb @@ -107,17 +107,20 @@ def install args << "--without-gcc" if ENV.compiler == :clang + cflags = [] + ldflags = [] + cppflags = [] + unless MacOS::CLT.installed? # Help Python's build system (setuptools/pip) to build things on Xcode-only systems # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) - cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" - ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" - args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib + cflags << "-isysroot #{MacOS.sdk_path}" + ldflags << "-isysroot #{MacOS.sdk_path}" + cppflags << "-I#{MacOS.sdk_path}/usr/include" # find zlib + # For the Xlib.h, Python needs this header dir with the system Tk if build.without? "tcl-tk" - cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" + cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" end - args << cflags - args << ldflags end # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/ args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" @@ -148,10 +151,14 @@ def install if build.with? "tcl-tk" tcl_tk = Formula["tcl-tk"].opt_prefix - ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" - ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" + cppflags << "-I#{tcl_tk}/include" + ldflags << "-L#{tcl_tk}/lib" end + args << "CFLAGS=#{cflags.join(' ')}" unless cflags.empty? + args << "LDFLAGS=#{ldflags.join(' ')}" unless ldflags.empty? + args << "CPPFLAGS=#{cppflags.join(' ')}" unless cppflags.empty? + system "./configure", *args system "make"