homebrew-core/Formula/wxmac.rb
Samuel John f6e80bdea2 Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.

To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.

The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:

python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.

Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.

python do
  system python, 'setup.py', "--prefix=#{prefix}"
end

Read more in the Homebrew wiki.
2013-06-03 17:29:43 +02:00

96 lines
2.4 KiB
Ruby

require 'formula'
class FrameworkPython < Requirement
fatal true
satisfy do
q = `python -c "import distutils.sysconfig as c; print(c.get_config_var('PYTHONFRAMEWORK'))"`
not q.chomp.empty?
end
def message
"Python needs to be built as a framework."
end
end
class Wxmac < Formula
homepage 'http://www.wxwidgets.org'
url 'http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.0.tar.bz2'
sha1 'c292cd45b51e29c558c4d9cacf93c4616ed738b9'
depends_on :python => :recommended
depends_on FrameworkPython if build.with? "python"
def install_wx_python
args = [
# Reference our wx-config
"WX_CONFIG=#{bin}/wx-config",
# At this time Wxmac is installed Unicode only
"UNICODE=1",
# Some scripts (e.g. matplotlib) expect to `import wxversion`, which is
# only available on a multiversion build. Besides that `import wx` still works.
"INSTALL_MULTIVERSION=1",
# OpenGL and stuff
"BUILD_GLCANVAS=1",
"BUILD_GIZMOS=1",
"BUILD_STC=1"
]
cd "wxPython" do
ENV.append_to_cflags '-arch x86_64' if MacOS.prefer_64_bit?
python do
system python, "setup.py",
"build_ext",
"WXPORT=osx_cocoa",
*args
system python, "setup.py",
"install",
"--prefix=#{prefix}",
"WXPORT=osx_cocoa",
*args
end
end
end
def install
# need to set with-macosx-version-min to avoid configure defaulting to 10.5
args = [
"--disable-debug",
"--prefix=#{prefix}",
"--enable-unicode",
"--enable-std_string",
"--enable-display",
"--with-opengl",
"--with-osx_cocoa",
"--with-libjpeg",
"--with-libtiff",
"--with-libpng",
"--with-zlib",
"--enable-dnd",
"--enable-clipboard",
"--enable-webkit",
"--enable-svg",
"--with-expat",
"--with-macosx-version-min=#{MacOS.version}"
]
system "./configure", *args
system "make install"
if build.with? "python"
ENV['WXWIN'] = Dir.getwd
# We have already downloaded wxPython in a bundle with wxWidgets
install_wx_python
end
end
def caveats
s = ''
fp = FrameworkPython.new
unless build.without? 'python' or fp.satisfied?
s += fp.message
end
return s
end
end