Introduction
Packaging your software for installation is
a difficult, nasty, unpleasant, arduous, error-prone task. It is
awfully enticing to just give up, zip up your Python source code
together with a README file, and leave it at that.
In some cases, doing just that might be
wise: if your intended users are technically knowledgeable, you
can ask them to install Python, edit system variables, and mess
around until everything works. Typically, though, more than this
is expected.
The first problem of packaging an
application for installation arises because of the wide variety
of platforms a PyQt application will run on: Classic Unix,
Linux, the free BSDs, Windows in its infinite variety and
finally OS X. Depending upon your target audience, one or more
of these platforms can be dropped. If your application is open
source, you might be able to get other developers to package
your application for their platform.
The second problem is that Python has
several methods of packaging applications. The standard is
Distutils, which comes with the
Python distribution. Then there is
freeze, Gordon McMillan's
Installer, Fredrik Lundh's
Squeeze (which is packaged with the
PythonWorks IDE), and finally Thomas
Heller's py2exe (which makes use of
Distutils). There are also generic
commercial solutions, such as Wise or
InstallShield (both for Windows) and
InstallAnywhere (for all platforms
that support Java). Furthermore, there are free alternatives,
such as rpm or dpgk for Unix. This breadth of choice alone
points to the fact that creating installation packages is a
difficult problem that has yet to be solved.
Distutils is the standard Python solution
and comes with Python 2.x. It appears to be more geared to
distribution modules and libraries, and less to distributing
applications. If you want something that generates stand-alone
executables of an application, you might want to try Gordon
McMillan's Installer (http://www.mcmillan-inc.com/builder.html).
BlackAdder will probably provide an installation utility in a
future version, and it will probably be based on
Distutils.
The third problem (they do mount up) is
that you cannot assume that your user has Python installed. You
must choose whether you want your users to install Python
themselves, or package a complete Python installation with your
application. The first option is perfectly feasible on Linux,
because installing Python using either rpm or apt-get is easy
enough. The second option might be feasible on Windows, as
Python for windows comes with a very nice and easy installer. Of
course, Windows users are generally a bit lazier than Unix
users, and might not want to install another package before they
can start using your application.
The fourth problem is the presence, or
absence, of PyQt. Again, most modern Linux distributions include
PyQt, so users can just grab the rpm or deb package, and go. As
for Windows, you can freely redistribute the runtime components
that come with BlackAdder, if you have bought the professional
version or the non-commercial PyQt and Qt libraries.
The fifth problem arises if you have used
third-party modules that require separate compilation for each
platform, and separate installation.
A sixth problem arises if you have written
extensions in C or C++ as part of your application or library,
and want to distribute those, too.
Finally, it's difficult to achieve even a
little integration with the user's desktop. All user interface
platforms Qt supports - Windows, KDE, Gnome, CDE, OS X and
others have wildly different standards for menu options, desktop
icons, mime-type integration (for those open file with
application menu's). This is, perhaps, the hardest, as it
requires knowledge of all relevant desktop environments.
This chapter will cover the creation of
source packages, Windows installers and Unix rpms using the
standard Distutils package. This
requires that the user has already installed Python, PyQt, and
any other libraries. The Redhat Package Manager (rpm) on Linux
can be told to check for these dependencies. On Windows, it's a
matter of forcing your users to read the manual. I don't
describe the process of packaging your own C or C++ extensions,
though it is possible. Consult the Distutils manual for more
information.