aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/python.rb
diff options
context:
space:
mode:
authorSamuel John2012-12-17 17:49:16 +0100
committerMike McQuaid2013-01-11 09:46:30 +0000
commit1d8f01d8af394a7501f5bf3a1e51796c1a7548a1 (patch)
treef500b428bec8a8ba4e9a8f40b9fc0c5cd10d0b86 /Library/Formula/python.rb
parente4f8f099062e1281640f6b9a8150e81c6b649276 (diff)
downloadhomebrew-1d8f01d8af394a7501f5bf3a1e51796c1a7548a1.tar.bz2
python: Allow --with-brewed-tk.
- Fixes #16574. - Improve Tkinter test by actually calling Tk() - Check for /Library/Frameworks/Tk.framework no longer needed. - Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful. Closes #16626. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula/python.rb')
-rw-r--r--Library/Formula/python.rb65
1 files changed, 37 insertions, 28 deletions
diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb
index 43323a272..c8d3feab6 100644
--- a/Library/Formula/python.rb
+++ b/Library/Formula/python.rb
@@ -1,20 +1,5 @@
require 'formula'
-class TkCheck < Requirement
- def message; <<-EOS.undent
- Tk.framework was detected in /Library/Frameworks
- This can cause Python builds to fail. See:
- https://github.com/mxcl/homebrew/issues/11602
- EOS
- end
-
- def fatal?; false; end
-
- def satisfied?
- not File.exist? '/Library/Frameworks/Tk.framework'
- end
-end
-
class Distribute < Formula
url 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.34.tar.gz'
sha1 'b6f9cfbaf3e63833b71009812a613be13e68f5de'
@@ -30,28 +15,29 @@ class Python < Formula
url 'http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2'
sha1 '842c4e2aff3f016feea3c6e992c7fa96e49c9aa0'
- depends_on TkCheck.new
- depends_on 'pkg-config' => :build
- depends_on 'readline' => :recommended
- depends_on 'sqlite' => :recommended
- depends_on 'gdbm' => :recommended
- depends_on 'openssl' if build.include? 'with-brewed-openssl'
-
option :universal
option 'quicktest', 'Run `make quicktest` after the build'
option 'with-brewed-openssl', "Use Homebrew's openSSL instead of the one from OS X"
+ option 'with-brewed-tk', "Use Homebrew's Tk (has optional Cocoa and threads support)"
option 'with-poll', 'Enable select.poll, which is not fully implemented on OS X (http://bugs.python.org/issue5154)'
-
# --with-dtrace relies on CLT as dtrace hard-codes paths to /usr
option 'with-dtrace', 'Experimental DTrace support (http://bugs.python.org/issue13405)' if MacOS::CLT.installed?
+ depends_on 'pkg-config' => :build
+ depends_on 'readline' => :recommended
+ depends_on 'sqlite' => :recommended
+ depends_on 'gdbm' => :recommended
+ depends_on 'openssl' if build.include? 'with-brewed-openssl'
+ depends_on 'homebrew/dupes/tk' if build.include? 'with-brewed-tk'
+
def patches
p = []
# python fails to build on NFS; patch is merged upstream, will be in next release
# see http://bugs.python.org/issue14662
p << "https://gist.github.com/raw/4349132/25662c6b382315b5db67bf949773d76471bbcee7/python-nfs-shutil.diff"
p << 'https://raw.github.com/gist/3415636/2365dea8dc5415daa0148e98c394345e1191e4aa/pythondtrace-patch.diff' if build.include? 'with-dtrace'
-
+ # Patch to disable the search for Tk.frameworked, since homebrew's Tk is a plain unix build
+ p << DATA if build.include? 'with-brewed-tk'
p
end
@@ -182,6 +168,7 @@ class Python < Formula
s.gsub!(/^CXX=.*$/, "CXX=xcrun clang++")
s.gsub!(/^AR=.*$/, "AR=xcrun ar")
s.gsub!(/^RANLIB=.*$/, "RANLIB=xcrun ranlib")
+ s.gsub!(/^PYTHONFRAMEWORKDIR=\tPython\.framework/, "PYTHONFRAMEWORKDIR= #{opt_prefix}/Frameworks/Python.framework")
end
end
@@ -196,11 +183,13 @@ class Python < Formula
# Help Python's build system (distribute/pip) to build things on Xcode-only systems
# The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot)
cflags += " -isysroot #{MacOS.sdk_path}"
- # For the Xlib.h, Python needs this header dir
- cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
ldflags += " -isysroot #{MacOS.sdk_path}"
# Same zlib.h-not-found-bug as in env :std (see below)
args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include"
+ # For the Xlib.h, Python needs this header dir with the system Tk
+ unless build.include? 'with-brewed-tk'
+ cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
+ end
end
args << cflags
args << ldflags
@@ -245,7 +234,7 @@ class Python < Formula
Homebrew's Python framework
#{prefix}/Frameworks/Python.framework
- Python demo
+ Python demo #{'🐍' if MacOS.version >= :lion}
#{HOMEBREW_PREFIX}/share/python/Extras
Distribute and Pip have been installed. To update them
@@ -260,6 +249,7 @@ class Python < Formula
They will install into the site-package directory
#{site_packages}
+
Executable python scripts will be put in:
#{scripts_folder}
so you may want to put "#{scripts_folder}" in your PATH, too.
@@ -273,6 +263,25 @@ class Python < Formula
# and it can occur that building sqlite silently fails if OSX's sqlite is used.
system "#{bin}/python", "-c", "import sqlite3"
# Check if some other modules import. Then the linked libs are working.
- system "#{bin}/python", "-c", "import Tkinter"
+ system "#{bin}/python", "-c", "import Tkinter; root = Tkinter.Tk()"
end
end
+
+__END__
+diff --git a/setup.py b/setup.py
+index 6b47451..b0400f8 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1702,9 +1702,9 @@ class PyBuildExt(build_ext):
+ # AquaTk is a separate method. Only one Tkinter will be built on
+ # Darwin - either AquaTk, if it is found, or X11 based Tk.
+ platform = self.get_platform()
+- if (platform == 'darwin' and
+- self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
+- return
++ # if (platform == 'darwin' and
++ # self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
++ # return
+
+ # Assume we haven't found any of the libraries or include files
+ # The versions with dots are used on Unix, and the versions without