Sarah,

The good news is that it *can* be done.  I know because I'm on Lion, and I'm 
using wxHaskell.

On 25 Feb 2012, at 14:58, Sarah Brofeldt wrote:
> I've been trying frantically to get a working setup of wxHaskell and
> wxWidgets on my Mac recently, but to no avail. I was wondering if
> anyone knows how exactly to go about it. I've tried just about every
> combination of old and new versions of wxWidgets from homebrew as well
> as older wxcore releases. How do you do it?


The bad news is that it may still involve manually applying some patches (I'm 
not up to speed about the latest state of wxHaskell) and also installing 
wxWidgets by hand.

Your two challenges are to install the right wxWidgets version with the right 
set of flags (you want Unicode, for starters), and then to get a version of 
wxhaskell that works with it.  I'm using wxWidgets 2.9, for what it's worth

If you use Homebrew, I have a formula for a wxmac2.9 by Alessandro Vermeulen 
(attached)
require 'formula'

def build_python?; ARGV.include? "--python"; end

def which_python
  if ARGV.include? '--system-python'
    '/usr/bin/python'
  else
    'python'
  end
end

class Wxpython < Formula
  url 'http://downloads.sourceforge.net/project/wxpython/wxPython/2.9.2.4/wxPython-src-2.9.2.4.tar.bz2'
  md5 '8dae829b3bb3ccfe279d5d3948562c5f'
end

class Wxmac29 < Formula
  url 'http://downloads.sourceforge.net/project/wxwindows/2.9.2/wxWidgets-2.9.2.tar.bz2'
  homepage 'http://www.wxwidgets.org'
  md5 'd6cec5bd331ba90b74c1e2fcb0563620'

  def options
    [
      ['--python', 'Build Python bindings'],
      ['--system-python', 'Build against the OS X Python instead of whatever is in the path.']
    ]
  end

  def test_python_arch
    system "arch -i386 #{which_python} --version"
  rescue
    onoe "No python on path or default python does not support 32-bit."
    puts <<-EOS.undent
      Your default python (if any) does not support 32-bit execution, which is
      required for the wxmac python bindings. You can install the Homebrew
      python with 32-bit support by running:

      brew install python --universal --framework

    EOS
    exit 99
  end

  def install_wx_python
    opts = [
      # Reference our wx-config
      "WX_CONFIG=#{bin}/wx-config",
      # At this time Wxmac is installed ANSI only
      "UNICODE=0",
      # And thus we have no need for multiversion support
      "INSTALL_MULTIVERSION=0",
      # TODO: see if --with-opengl can work on the wxmac build
      "BUILD_GLCANVAS=0",
      # Contribs that I'm not sure anyone cares about, but
      # wxPython tries to build them by default
      "BUILD_STC=0",
      "BUILD_GIZMOS=0"
    ]
    Dir.chdir "wxPython" do
      system "arch", "-i386",
                     which_python,
                     "setup.py",
                     "build_ext",
                     *opts

      system "arch", "-i386",
                     which_python,
                     "setup.py",
                     "install",
                     "--prefix=#{prefix}",
                     *opts
    end
  end

  def install
    test_python_arch if build_python?

    # Force i386
    # %w{ CFLAGS CXXFLAGS LDFLAGS OBJCFLAGS OBJCXXFLAGS }.each do |compiler_flag|
      # ENV.remove compiler_flag, "-arch x86_64"
      # ENV.append compiler_flag, "-arch i386"
    # end

    system "./configure", "--disable-debug", "--disable-dependency-tracking",
                          "--prefix=#{prefix}",
                          "--enable-unicode",
                          "--with-osx_cocoa",
                          "--with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk"
                          # "--with-macosx-version-min=10.6"
    system "make install"

    if build_python?
      ENV['WXWIN'] = Dir.getwd
      Wxpython.new.brew { install_wx_python }
    end
  end

  def caveats
    s = <<-EOS.undent
      wxWidgets 2.8.x builds 32-bit only, so you probably won''t be able to use it
      for other Homebrew-installed softare on Snow Leopard (like Erlang).

    EOS

    if build_python?
      s += <<-EOS.undent
        Python bindings require that Python be built as a Framework; this is the
        default for Mac OS provided Python but not for Homebrew python (compile
        using the --framework option).

        You will also need 32-bit support for Python. If you are on a 64-bit
        platform, you will need to run Python in 32-bit mode:

          arch -i386 python [args]

        Homebrew Python does not support this by default (compile using the
        --universal option)

      EOS
    end

    return s
  end
end

For the wxHaskell patches, unless somebody from the team obsoletes my message, 
you should be able to grab them at this old thread http://ur1.ca/8erik and 
apply them using something like

darcs get --lazy http://code.haskell.org/wxhaskell 
the-patch-you-downloaded.dpatch
cd wxhaskell
darcs apply -i ~/foo/the-patch-you-downloaded.dpatch

See also the NOTES file in the thread.

If this helps you get set up, I think it would be fantastic service to your 
fellow Mac-using GUI-writing Haskellers if you could help make such a guide in 
http://www.haskell.org/haskellwiki/WxHaskell/MacOS_X

Sorry this isn't a more helpful answer.  I haven't been keeping up :-(
But hopefully somebody else will step into the breach and give a better guide.

If you're still stuck after this, shout and I'll see if I can do more digging.

-- 
Eric Kow <http://erickow.com>

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

Reply via email to