PyQt on the Mac: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Still working on this article... not sure how things will shake out yet. Come back tomorrow.
PyQt is a set of bindings for Python that allow you to build applications using the QT framework. So, in theory you can build one application that runs on any platform that supports Python and QT. This includes Macintosh, Linux, and Windows.
PyQt is a set of bindings for Python that allow you to build applications using the QT framework. So, in theory you can build one application that runs on any platform that supports Python and QT. This includes Macintosh, Linux, and Windows.


There is no binary installer for Macintosh.
= PyQT on my Mac =
 
My computer is:
* MacBook Pro running Snow Leopard 10.6.3
* 64-bit Core Duo 2 processor, 8 GB ram, 500 gb disk
 
There is currently no binary installer for this configuration, you have to build it.
 
I went down the path of installing the first copy of QT that I found at the Nokia site, then tried to build and install PyQT only to have it gripe that the QT installation was 32-bit.
 
I searched and found files marked as 64-bit versions of the QT binaries tucked away [http://qt.nokia.com/downloads/mac-os-cpp here]. It ''says'' 64-bit but appears to still be 32-bit. Or maybe the PyQT build is really finding one of the previously installed 32-bit versions.
 
But for some reason installing those did not help either.
So, back to the drawing board.


First you have to build and install '''SIP'''. SIP is a tool for creating C/C++ bindings.
== Building QT 4.6.2 for 64-bit ==


Then you have to build and install '''PyQT'''.
First I deleted all the copies of Qt left floating around my system in /Applications, /Developer/Applications, /Developer/Tools, and /usr/local from previous attempts.


For QT:
Then I downloaded the latest source tarball from http://qt.nokia.com/downloads


  export CCFLAGS="--arch=x86_64"
  ./configure -arch x86_64
./configure
  make
  make
  sudo make install
  sudo make install
unset CCFLAGS


For QT Creator:
This build is taking a ''long'' time on my MacBook. But at least this time I can see it's building a 64-bit app. The compile lines flying by contain the -arch x86_64 tag. This is promising.
 
When it's done I will have... what? I think it installs into /usr/local by default. Not very Mac-ish but as a Linux hack I think it's a fine place.


export CCFLAGS="--arch=x86_64"
== Building PyQT ==
./configure
 
make
First you have to build and install '''SIP'''. SIP is a tool for creating C/C++ bindings. Then you have to build and install '''PyQT'''.
sudo make install
unset CCFLAGS


For SIP:
For SIP:


  export MACOSX_DEPLOYMENT_TARGET=10.6
  export MACOSX_DEPLOYMENT_TARGET=10.6
  python configure.py -n -d /Library/Python/2.6/site-packages -b /usr/local/bin -e /usr/local/include -v /usr/local/share/sip --arch=x86_64 -s MacOSX10.6.sdk
  python configure.py -b /usr/local/bin -e /usr/local/include -v /usr/local/share/sip --use-arch=x86_64
  make
  make
  sudo make install
  sudo make install
Line 36: Line 49:
  make
  make
  sudo make install
  sudo make install
You will get a lot of warnings about "Support for this version of Mac OS X is still preliminary", but they're harmless (so far).
</pre>

Latest revision as of 15:21, 19 May 2010

Still working on this article... not sure how things will shake out yet. Come back tomorrow.

PyQt is a set of bindings for Python that allow you to build applications using the QT framework. So, in theory you can build one application that runs on any platform that supports Python and QT. This includes Macintosh, Linux, and Windows.

PyQT on my Mac

My computer is:

  • MacBook Pro running Snow Leopard 10.6.3
  • 64-bit Core Duo 2 processor, 8 GB ram, 500 gb disk

There is currently no binary installer for this configuration, you have to build it.

I went down the path of installing the first copy of QT that I found at the Nokia site, then tried to build and install PyQT only to have it gripe that the QT installation was 32-bit.

I searched and found files marked as 64-bit versions of the QT binaries tucked away here. It says 64-bit but appears to still be 32-bit. Or maybe the PyQT build is really finding one of the previously installed 32-bit versions.

But for some reason installing those did not help either. So, back to the drawing board.

Building QT 4.6.2 for 64-bit

First I deleted all the copies of Qt left floating around my system in /Applications, /Developer/Applications, /Developer/Tools, and /usr/local from previous attempts.

Then I downloaded the latest source tarball from http://qt.nokia.com/downloads

./configure -arch x86_64
make
sudo make install

This build is taking a long time on my MacBook. But at least this time I can see it's building a 64-bit app. The compile lines flying by contain the -arch x86_64 tag. This is promising.

When it's done I will have... what? I think it installs into /usr/local by default. Not very Mac-ish but as a Linux hack I think it's a fine place.

Building PyQT

First you have to build and install SIP. SIP is a tool for creating C/C++ bindings. Then you have to build and install PyQT.

For SIP:

export MACOSX_DEPLOYMENT_TARGET=10.6
python configure.py -b /usr/local/bin -e /usr/local/include -v /usr/local/share/sip --use-arch=x86_64
make
sudo make install

For PyQt:

export QTDIR=/Developer/Applications/Qt
python configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin --use-arch=x86_64
make
sudo make install