Pyqtdeploy is a tool for deploying PyQt applications. It supports deployment to desktop platforms (Linux, Windows and macOS) and to mobile platforms (iOS.
Share this story. The open source Qt development toolkit is a popular choice for cross-platform development. It provides native-looking widgets and tight integration with the underlying platform on Windows, Linux, and Mac OS X. Qt applications that are written in C are easy to compile and deploy across all three platforms, but what if you don't like C? I prefer Python, a dynamic programming language with a richly expressive syntax and exceptionally powerful support for introspection. Fortunately, there are cross-platform Python bindings for Qt.
The downside, however, is that packaging PyQt applications so that they can be deployed to users on Windows and Mac OS X is an immensely frustrating and arcane process. I declared victory last week after spending several hours battling with MacPorts and distutils. Now that I have unlocked the toolkit's dark mysteries, I can show you the hidden secrets that will allow you to achieve mastery of the alchemical art of cross-platform PyQt application deployment. First, you'll need access to each platform for which you want to build redistributable packages.
The easiest way to accomplish this is to use a Mac and either triple-boot or virtualize Windows and Linux. The initial setup process for Mac OS X will require a lot of very heavy compilation, so you are going to be in for a world of pain and a very long wait if you try to do this on a Mac mini.
My test application My computing environment is a quad core Mac Pro configured to dual-boot OS X and openSUSE 11.1. For Windows, I'm running XP in VirtualBox. I do most of my actual development in Linux, but you can do it pretty comfortably on any of the platforms. My test application, which I call Orbital Liftr, is a simple utility that I made for batch uploading graphics to Ars Technica's content management system. The Ars CMS is built on Movable Type, which means that it supports the MetaWeblog XML-RPC API, and my app lets you upload images to any standard Movable Type or WordPress blog that supports the API. The app has a few simple features like support for receiving images via drag-and-drop, and it can proportionally resize them before uploading.
The program consists of one module of Python code which contains the application logic and a few basic user interface forms that I made with the Qt Designer program. I have published the of the program. You can use it to follow along with this tutorial, or you can use your own code. PyQt on Windows.
This is part of a continuing series of blogs of my experience using pyqtdeploy. You might want to start at the tutorial which I link at the bottom of the blog. This blog really adds nothing except some discussion of why and how to get the required tools, and some context for pyqtdeploy. Here, I have switched host development platform (now MacOS or OSX) and target (now iOS.) I switched because I encountered difficulties porting to Android.
I decided to digress, in hopes that what I learn on a different target (iOS instead of Android) might teach me something. Besides, MacOS has always been a highly regarded development platform, and many pyqtdeploy example screenshots seem to be from MacOS. If you are using pyqtdeploy, then you probably want to port to all supported platforms, and you should choose the path of least resistance. There is no use struggling with one platform (Android) especially if, like me, you are equally unfamiliar with all the mobile platforms or if one platform (iOS) might be better supported, more stable, etc. The process has three parts:. set up tools.
compile libraries statically. compile your app This is part one, setting up tools. The goal is to get a Qt example app running on iOS.
Getting an example to run is not required to use pyqtdeploy. It is just a milestone, that insures you have a proper build environment. This blog assumes you want point-and-click. You can use Xcode and Qt Creator tools from the command line, without using their GUI’s.
During the second part, you WILL be using the command line to build static libraries. But you probably would not be reading this if you already know the commands. And learning the GUI versions of the tools may guide you. Required Tools You need:.
Xcode. Qt Creator Pyqtdeploy uses qmake, which is packaged with Qt Creator. (Again, later, you might be able to forego Qt Creator, and use the command line.) Qt Creator and qmake invoke tools (compilers etc.) that are packaged with Xcode. Which versions of tools I used:. OSX 10.9.4 Mavericks. Qt5.3.0. Xcode 5.1.1.
Qt Creator 3.1.1 I briefly tried to use OSX 10.7.5, Xcode 4.6.3, and Qt 5.2. But it didn’t work and I decided there was no point not to use the latest tools. Everyone else is moving forward. Qt on mobile platforms is bleeding edge. In my experience, Qt 5.3 is much better than older versions.
Xcode 4.6.3 will actually be two major versions behind, now that Xcode 6 is imminently released. Downloading the tools The links are easy to find.
My advice is to download the entire Xcode (rather than say just the command line tools.) My advice is to use the “online installer” to install Qt and its tools. It is a small, smart installer that downloads and installs other components.
It will know your platform and offer you choices to download the proper kits for iOS. Installing additional Qt components I think I had installed Qt without using the online installer. It did not include kits for iOS.
So I needed to install additional Qt components. About Qt Creator kits The tells you how to add kits in Qt Creator. Kits are groups of settings for building apps. You usually don’t need to create or customize a kit, only use a kit that is distributed with Qt. When you open a project, including the Qt examples, you are given the chance to configure the kit for the project.
Install Pyqt5 On Mac
But you must have previously downloaded the kit (which Qt Creator then detects.) In this example, I wanted the kit for the ‘iOS Simulator.’ Downloading additional kits You use the Qt ‘Maintenance Tool’ and choose ‘Package Manager’. If you previously used the Qt ‘online installer’, then when you start the Maintenance Tool it remembers the repository used previously, and gives you choices of additional packages. Otherwise, you might get an error ‘requires a valid repository’.
How To Deploy Pyqt Applications For Mac Os X
To fix this:. start the Maintenance tool. choose the Settings button, a dialog should open. choose the Repositories tab. select ‘User specified’.
choose the Add button. enter and so forth. After you do this, the Maintenance Tool should offer you the choice of downloading additional kits.
Building a Qt example Follow this good, short video tutorial. The analog clock example (without menus) worked for me. What’s next The next part will build static libraries for Python, PyQt, and SIP, for the iOS platform.