Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Python/Python3: Fix RuntimeError: tk.h version (8.6) doesn't match libtk.a version (8.5) #41728

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Library/Formula/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 15 additions & 8 deletions Library/Formula/python3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down