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)
 
(3 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.


First you have to build and install '''SIP'''. SIP is a tool for creating C/C++ bindings.
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.


Then you have to build and install '''PyQT'''.
But for some reason installing those did not help either.
So, back to the drawing board.


From http://old.nabble.com/PyQt4,-Qt-on-osx-SnowLeopard-td26394590.html
== Building QT 4.6.2 for 64-bit ==
<pre>
Re: PyQt4, Qt on osx SnowLeopard


by William Kyngesburye Nov 17, 2009; 10:22am :: Rate this Message: - Use ratings to moderate (?)
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.


Reply | Print | View Threaded | Show Only this Message
Then I downloaded the latest source tarball from http://qt.nokia.com/downloads
Here's what I do for using a 32bit Qt 4.5.x (binary distribution), with SIP 3.9 and PyQt 4.6. The key is to use the new arch flags in the current SIP and PyQt versions.
 
./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:
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=i386 -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


For PyQt:
For PyQt:


export QTDIR=/Developer/Applications/Qt
export QTDIR=/Developer/Applications/Qt
python configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin --use-arch=i386
python configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin --use-arch=x86_64
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