Shallow Thoughts : tags : meego

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Fri, 20 May 2011

Packaging Python for MeeGo (or other RPM-based distros)

Writing Python scripts for MeeGo is easy. But how do you package a Python script in an RPM other MeeGo users can install?

It turned out to be far easier than I expected. Python and Ubuntu had all the tools I needed.

First you'll need a .desktop file describing your app, if you don't already have one. This gives window managers the information they need to show your icon and application name so the user can run it. Here's the one I wrote for PyTopo: pytopo.desktop.

Of course, you'll also want a desktop icon. Most other applications on MeeGo seemed to use 48x48 pixel PNG images, so that's what I made, though it seems to be quite flexible -- an SVG is ideal.

With your script, desktop file and an icon, you're ready to create a package.

Create a file describing your package, as in the distutils simple example or the more detailed distutils setup script page. For a sample standalone script with a desktop file and icon, you can take a look at my PyTopo

Starting from the Python setup script, Python's distutils can generate RPM or even Windows packages -- assuming you have the appropriate tools installed on your machine.

I'm on an Ubuntu (Debian-based) machine, and all the docs imply you have to be on an RPM-based distro to make an RPM. Happily, that's not true: Ubuntu has RPM tools you can install.

$ sudo apt-get install rpm

Then let Python do its thing:

$ python bdist_rpm

Python generates the spec file and everything else needed and builds a multiarch RPM that's ready to install on MeeGo. You can install it by copying it to the MeeGo device with scp dist/PyTopo-1.0-1.noarch.rpm meego@address.of.device:/tmp/. Then, as root on the device, install it with rpm -i /tmp/PyTopo-1.0-1.noarch.rpm. You're done!

To see a working example, you can browse my latest PyTopo source (only what's in SVN; it needs a few more tweaks before it's ready for a formal release). Or try the RPM I made for MeeGo: PyTopo-1.0-1.noarch.rpm. I'd love to hear whether this works on other RPM-based distros.

What about Debian packages?

Curiously, making a Debian package on Debian/Ubuntu is much less straightforward even if you're starting on a Debian/Ubuntu machine. Distutils can't do it on its own. There's a Debian Python package recipe, but it begins with a caution that you shouldn't use it for a package you want to submit. For that, you probably have to wade through the Complete Ubuntu Packaging Guide. Clearly, that will need a separate article.

Tags: , , , ,
[ 18:44 May 20, 2011    More programming | permalink to this entry | ]

Sat, 07 May 2011

Overview of MeeGo Development Tools

Over the past week I've been playing with the MeeGo ExoPC tablet, experimenting with the various options for building programs.

One advantage MeeGo has over Android or iOS is that there are quite a lot of language and toolkit options. If you have an existing program, especially if it runs on Linux, you can probably find a way to port it to MeeGo fairly without much extra coding.

But since MeeGo is still quite new, not all of the options work quite as well as you might hope -- yet. I'm sure they'll get better, but here's what the development climate looks like now.

C++, Qt and Meego SDK

C++ and Qt are the primary supported environment on MeeGo, via the MeeGo SDK, run in an IDE called QtCreator.

The documentation turns out to be somewhat incomplete; I'll write up a howto as a separate article. But once you get it installed (much easier than installing, say, Eclipse for Android), it runs nicely. You can use normal Qt, not a specialized environment, so existing Qt programs should be quick to port, and the IDE takes care of packaging, copying the app to your remote device and starting it running. Very painless.

Testing apps locally isn't so easy. They're set up to use QEMU, which only works if your development machine has hardware virtualization. Supposedly there's a way to make this work in virtualbox (which doesn't require hardware virtualization), but the docs don't address how.

Still, testing on the target device is easy. Unfortunately, not many of my existing programs are C++ and Qt. I mostly write Python, C, and Javascript/HTML web apps.

Update: I should have mentioned that QtCreator also lets you program in QML, an XML-like language that lets you design Qt user interface and even write application code.

Web Apps under C++ and QWebView

So what about those web apps? Since the C++ SDK was so well supported, I figured, why not use a QWebView so I can run my HTML and Javascript code?

Unfortunately QWebView turns out to be tricky to use, has very few sample apps available, and so far I've been unable to get it to work under MeeGo at all.

Nokia Web RunTime

And anyway, for pure web apps, there's a kit explicitly for that: WRT, the Nokia Web RunTime. But it's pretty heavyweight: the official download and documentation is all based around Eclipse (for HTML/Javascript apps? Seriously?) and a required set of Nokia libraries that I had trouble installing.

But WRT apps are packaged according to the W3C Widget Packaging and Configuration specification -- so it's probably possible to roll your own without the big Nokia WRT package. More research required.

Python, Qt and PySide

I have a lot of Python apps, so I was very happy to see that Python comes already installed on MeeGo. (Perl is also supported; Ruby theoretically is but it's not installed by default.)

Since Qt is the officially blessed user interface, Python-Qt seems like the way to go. Except -- Python in MeeGo has no Qt bindings installed. The package that provides them is called PySide, but depending on where you look you'll either be steered toward a lengthy source compile on the MeeGo device, or a zypper install from someone's personal repository.

None of that is difficult for developers, but you can't expect users to enable experimental repositories or compile from source. Is PySide going to be a standard part of MeeGo by the time it ships to users? Nobody's saying. It makes me leery of putting much energy into Python-Qt development until I hear more.


A little frustrated with the options so far, I was idly poking around an interactive Python session and typed

>>> import gtk

And it worked! Even though Qt is the supported UI toolkit and nobody talks about GTK, it's installed on MeeGo -- complete with Python bindings. It gave two deprecation warnings, but what's a little deprecation among friends?

A simple test program ran just fine. So I whipped up a starter page for PyTopo, made a .desktop file and icon for it, copied the three files over with scp -- and everything worked great.

There's no standard way yet to make a MeeGo RPM from a Python program, so that will require a little hand-fiddling, but only a little. And sadly, python-webkit-gtk isn't included, so this isn't a good solution for porting web apps.

I'll be keeping an eye on PySide and continuing to experiment with PySide, WRT and C++. But in the meantime, it's great that it's so easy to port all my existing Python-GTK programs to MeeGo.

Tags: ,
[ 11:33 May 07, 2011    More programming | permalink to this entry | ]