PyPackager
For developers without a Linux-background and supporting hardware, getting into development on Maemo is most easily achieved by using PyMaemo, the Python port for Maemo. Check the website for more information on how to program - this wiki page only explains how to properly integrate your python app into the Maemo desktop environment.
Once you have a python application, you need to properly structure your source directory and add some additional files to achieve maximum Maemo/Hildon desktop integration. This document shall explain this, using the mClock build process as an example.
One remaining hurdle is the proper packaging of your app. This needs to be a Debian package, a *.deb file. As it is impossible to build such a package on Windows-based systems (different concept of permissions, no tools), you need to build it either on a Linux system - or you can directly do it on your Internet Tablet using the handy PyPackager tool from BenoƮt Hervier, aka Khertan. With it, you can simply select a source directory that then gets packaged into the final DEB file suitable for distribution over maemo.org downloads or your homepage. PS: If you plan to distribute your application using the integrated application manager and the extras repository, you must use another build process. Check the py2deb documentation for this.
Contents |
[edit] Recommendations
- OpenSSH server installed on the device
- Using a SFTP client on the Windows computer (e.g. Bitvise Tunnelier)
[edit] Process in general
- Login as root
- Upload your source directory to wherever you want (I suggest MyDocs <-- Not recommended for doing this on device, since the next step in this Section will fail. Use /home/user/myapp directory instead.)
- Change the permissions on files that later need to be executable to 755
- Open Pypackager, add the necessary information, select a source folder, save the settings. Tap the wheel icon to build your package.
- Use the Maemo File Manager to open the resulting .deb filename. It should automatically launch the Programs Manager and start to install your app.
- Debug - Rinse - Repeat
[edit] The folder structure
MyDocs or whatever root, containing the following files:
- mClock.png
- A 26x26 alpha transparency PNG with the icon that shall be included in the build as the package icon (as seen in the Programs Manager)
- mclock-pypackager
- The saved config file from PyPackager
- mclock-src
- the folder containing the source code; the structure of the subfolders must match the structure of how the app will be deployed on the system (read an intro to debain packaging such as the one reffered on the PyPackager homepage)
- usr
- the main subfolder, matches /usr
- bin
- folder containing the main executable, a mClock file with 755 permission, containing a link to the mClock.py file inside the lib/maemo subfolder
- lib
- folder with mClock subfolder containing all *.py files of the application
- share
- folder containing all elements responsible for Hildon integration
- applications/hildon subfolder
- contains a mClock.desktop file that defines how the mClock app appears in the Hildon menu system (Name, Subtitle when in Finger mode, Icon, Exec path, StartupWMClass to link running app to Task Navigator icon, corresponding service (only needed when doing communications over OSSO).
- dbus-1/services subfolder
- contains a mclock.service file that links the service name to the executable
- icons/hicolor subfolder
- contains PNG icons in two sizes, used by the Menu System (small one when in pen mode under 26x26\hildon; large one for finger mode under scalable/hildon, in a size of 48x48)
- mClock subfolder
- containing all resources used by the application that are NOT executables, such as images.
- pixmaps subfolder
- dontaining the 48x48 icon once again for other uses by the system (TODO: anybody knows what for exactly?)
That's it. Quite simple once you have set it up properly. One thing: try to use a lowercase-only application name. Unix is case-sensitive, and choosing a name such as mClock was stupid from me. Don't do it. I did run into all sorts of troubles....
[edit] The files
Information about the *.desktop and *.service files plus some tips about needed stuff inside your python app.
[edit] mClock.desktop file
Main article: Desktop file format
[Desktop Entry] # Version of this file, NOT of the app. Keep it at 1.0.0 Version=1.0.0 Encoding=UTF-8 # Name of the app as seen in Menu Name=mClock # Description of the app as seen as subtitle in Menu in Finger mode Comment=Clock & day/night map # Link to the app Exec=/usr/bin/mClock # Name of our icon file, without the trailing .png part Icon=mclock # Path to the icon X-Icon-path=/usr/share/icons # Name of our icon file, without the trailing .png part (again?!) X-Window-Icon=mclock Type=Application # MUST begin with com.nokia. due to a bug, anything else will NOT work X-Osso-Service=com.nokia.mclock X-Osso-Type=application/x-executable # Only needed because it's a PyGame app (would be automatic with GTK) StartupWMClass=mClock
[edit] mclock.service
All lower case just to be sure. Very simple content:
[D-BUS Service] # MUST begin with com.nokia. due to a bug, anything else will NOT work Name=com.nokia.mclock # Link to the app Exec=/usr/bin/mClock
[edit] mClock.py
Some important snippets from my code...
The first one is to be set as early as wanted, it will make sure that the "Loading..." banner disappers. Only needed because this is a pure pygame app right now, wouldn't be needed when using GTK!
import os os.environ["SDL_VIDEO_X11_WMCLASS"]="mClock"
Later on, we need to connect to our osso service or the service daemon will kill our application!
osso_c = osso.Context("mclock", "0.2.1", False)
(However, don't ask me IF that version string has ANY relevance, I don't know)
[edit] mclock.pypackager
The saved pypackager file that contains my package definition. You can copy that into a text file and then load it from PyPackager to get my build configuration:
(S'mClock' S'0.5.5' S'user/other' S'all' S'Optional' S'Tom Waelti <twaelti@gmail.com>' S'python2.5 (>= 2.5.1-1osso5), python2.5-osso, python2.5-gnome (>= 2.18.0-1osso3)' S'A simple clock for maemo, incl. a day/night world map.\nPress D-Pad or bottom left to switch view mode.\nESC to exit.\nLeft/right D-Pad (or touching l/r border of screen)\nto change season. ' S'/home/user/MyDocs/mclock-src' S'/home/user/MyDocs/mClock.png' S'' S'' S'#!/bin/sh\ntouch /usr/lib/python2.5/site-packages/gnome/__init__.py\n' S'' S'' S'extras' S'chinook' S'low' S'email@email.com' S'' S'' S'login' S'1' tp1 .
- This page was last modified on 21 April 2012, at 14:27.
- This page has been accessed 33,319 times.